fetch sql server name & available databases

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MatA
Posts: 3
Joined: Tue 20 Jun 2006 11:59

fetch sql server name & available databases

Post by MatA » Tue 20 Jun 2006 12:08

Hi,

I am new to the SQL Server Data Access Components.

I have been looking at the ConnDialog demo & i like the way you can customise the SQL Server connect.

I have been developing my own application configuration screen & would like to utilise some of the MSConnectDialog features.

I have a configuration form which loads on an onclick event which uses a TabSheet, is there anyway to add combo boxes on there for the SQL Server list & database list for the selected server without calling up a seperate configuration screen?

I tried coding
MSConnectDialog.DialogClass:= 'TfmMain';
MSConnection.Connect;

Into my configuration screen launch button but im also using TIniFile to save selections to an ini file & put them back into edit boxes etc on load... when i try & do the TIniFile stuff on the config form with the above call it just doesn't do anything... i guess its to do with it being "virtual" :?:

Is there anyway of getting what im trying to achieve? I spent 2days on this now n just wana know if im wasteing my time?

Cheers in advance.

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Wed 21 Jun 2006 11:46

You can use MSAccess.GetServerList and MSAccess.GetDatabasesList to fill your comboboxes with this information.

MatA
Posts: 3
Joined: Tue 20 Jun 2006 11:59

Post by MatA » Thu 22 Jun 2006 10:50

that sounds exactly what i need, could you post some example code...
iv tried adding the GetDatabaseList to the ConnDiag demo but with no success. I need to make it as simple as possible really i dont require another connection screen to be launched, i need it all on the same form, if that makes sence?

Ill also be storing the selections in an ini file & reading them back on active... i tried this on the conndiag & it didnt like it...

Is it possible?

BTW,

Im running, Delphi 6 with SDAC Version 2.35.0.14.

Cheers again

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Fri 23 Jun 2006 11:32

> could you post some example code...

Code: Select all

  MSAccess.GetServerList(ComboBox1.Items);
  MSAccess.GetDatabasesList(MSConnection1, ComboBox2.Items);
> Ill also be storing the selections in an ini file...
You can freely store selections in ini file.

MatA
Posts: 3
Joined: Tue 20 Jun 2006 11:59

Post by MatA » Fri 23 Jun 2006 13:06

a ha.... got it working now...

;-) thankyou very much for your help...

is it possible to do a combo box for table select? or is that pushing it?

he he he

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Mon 26 Jun 2006 08:39

You can use TCustomDAConnection.GetTableNames method to populate a string list with the names of tables in the database.
Please see SDAC help for more information.

Post Reply