🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.ado
Article #2160

Re: List all database of a ms sql server

#2160
From: Viatcheslav V. Vassiliev
Date: Tue, 28 Oct 2003 10:10
80 lines
3138 bytes
You may need to change connection string to include data source and user
name/password.


void __fastcall TForm1::Button1Click(TObject *Sender)
{
 ADOConnection1->ConnectionString = WideString("Provider=SQLOLEDB;"
  "Integrated security=SSPI;Initial catalog=master;");
 ADOConnection1->Connected = true;
 try
 {
  OleVariant EmptyParam;
  EmptyParam.SetError(DISP_E_PARAMNOTFOUND);
  ADOConnection1->OpenSchema(siCatalogs, EmptyParam, EmptyParam,
ADODataSet1);

  while (!ADODataSet1->Eof)
  {
   ListBox1->Items->Add(ADODataSet1->FieldByName("CATALOG_NAME")->AsString);
   ADODataSet1->Next();
  }
 }
 __finally
 {
  ADOConnection1->Connected = false;
 }
}

//----------------------
Regards,
Viatcheslav V. Vassiliev
http://www.oledbdirect.com
The fastest way to access MS SQL Server,
MS Jet (Access) and Interbase (through OLEDB)


"Mike" <mikeh@gmx.de> �������/�������� � �������� ���������:
news:3f9d60c6@newsgroups.borland.com...
> HI,
>
> thanks for your answer. i have search, but can't find any example for bcb.
> could you give me any example how to determine all databases of a server
and
> write into a listbox?
>
> mike
>
> "Viatcheslav V. Vassiliev" <support@oledbdirect.com> schrieb im
Newsbeitrag
> news:3f9d4d78@newsgroups.borland.com...
> > TADOConnection->OpenSchema(siCatalogs, EmptyParam, EmptyParam,
MyDataSet);
> >
> > Examine contents of MyDataSet (CATALOG_NAME field).
> >
> > //----------------------
> > Regards,
> > Viatcheslav V. Vassiliev
> > http://www.oledbdirect.com
> > The fastest way to access MS SQL Server,
> > MS Jet (Access) and Interbase (through OLEDB)
> >
> >
> > "Mike" <mikeh@gmx.de> �������/�������� � �������� ���������:
> > news:3f9d43a0@newsgroups.borland.com...
> > > hi,
> > >
> > > i am working with ado and wondering myself who get a list of all
> databases
> > > of my ms sql server. does anybody can give me some code, that would
help
> > me?
> > >
> > > mike
> > >
> > >
> >
> >
>
>
Technical Details
Message-ID: <3f9e40c5$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3f9d43a0@newsgroups.borland.com> <3f9d4d78@newsgroups.borland.com> <3f9d60c6@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10698b,21d277be5b318302
X-Google-Attributes: gid10698b,public
X-Google-ArrivalTime: 2003-10-28 02:39:42 PST
From: "Viatcheslav V. Vassiliev" <support@oledbdirect.com>
Newsgroups: borland.public.cppbuilder.database.ado
References: <3f9d43a0@newsgroups.borland.com> <3f9d4d78@newsgroups.borland.com> <3f9d60c6@newsgroups.borland.com>
Subject: Re: List all database of a ms sql server
Date: Tue, 28 Oct 2003 13:10:56 +0300
Lines: 82
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 213.234.218.42
Message-ID: <3f9e40c5$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1067335877 213.234.218.42 (28 Oct 2003 02:11:17 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail