Enumeration APP for SQL servers Driver

forum.advanced.programming (1998-2005)
Sanjay Goel

Enumeration APP for SQL servers Driver

Post by Sanjay Goel » 02 Mar 2005, 02:31

 Posted by:  Sanjay Goel 

Anybody has a sample app which can
enable enumeration of SQL Servers and their databases.

I need to populate a combo-box in my app with all the SQL Server Driver
defined servers. Once a server is selected and a User name and Password is
supplied a combo-box should populate all the databases for that server.

If someone has a way to do this please let me know. If you have a sample add
please send it across.

Thanks
Sanjay

Martin Duty

Enumeration APP for SQL servers Driver

Post by Martin Duty » 02 Mar 2005, 14:34

 Posted by:  Martin Duty 

Hi Sanjay,

I've tried to find this my self, but could never find the right DLL to work
with. I have a work around, but this only works if you have SQL Tools
installed on the client.

Loop
Call REG.SetRootKey( HKEY_LOCAL_MACHINE )
Set bExists = REG.KeyExists( '/Software/Microsoft/MSSQLServer/Client/TDS' )
If not bExists
Break
Else
Set bOk = REG.OpenKey( '/Software/Microsoft/MSSQLServer/Client/TDS',
FALSE)
Set bOk = REG.EnumValues( strSqlServers )
If bOk
Call PalArrayDimCountNull ( strSqlServers, nDim )
While nDim >= 0
Call SalStrUpper( strSqlServers[nDim], strDefaultServer )
Call SalListAdd ( cmbIMASServerList, strDefaultServer )
Set nDim = nDim - 1
Break

HTH
--
Martin Duty
IT Manager
Underground Vaults & Storage, Inc.
TD 3.0 PFT2
Client Win 2K/XP
Database MS Sql Server 2000

Martin Duty

Enumeration APP for SQL servers Driver

Post by Martin Duty » 02 Mar 2005, 20:55

 Posted by:  Martin Duty 

I also found this VB code on MS site:

Private Sub Command1_Click()
Dim i As Integer
Dim oNames As SQLDMO.NameList
Dim oSQLApp As SQLDMO.Application
Set oSQLApp = New SQLDMO.Application

Set oNames = oSQLApp.ListAvailableSQLServers()
List1.Clear
For i = 1 To oNames.Count
List1.AddItem oNames.Item(i)
Next i
End SubNow if I can figure out how to convert it to TD, but I don't use or
know VB.... oh well...
--
Martin Duty
IT Manager
Underground Vaults & Storage, Inc.
TD 3.0 PFT2
Client Win 2K/XP
Database MS Sql Server 2000

Sanjay Goel

Enumeration APP for SQL servers Driver

Post by Sanjay Goel » 02 Mar 2005, 23:45

 Posted by:  Sanjay Goel 

Martin

Thanks for your reply on the TeamDeveloper forum

Can you email me the complete Gupta APP or the VB application (In your 2nd
response) so that I can get the complete code. If you don't have the app can
you give me the link where you saw the VB code

Martin Duty

Enumeration APP for SQL servers Driver

Post by Martin Duty » 03 Mar 2005, 14:37

 Posted by:  Martin Duty 

I've gotten a bit farther. I created the APL for
C:\Program Files\Microsoft SQL Server\80\Tools\Binn\SQLDMO.dll

Just point ActiveX Explorer to that and you can create your own. I'm still
playing with that. The web sites I found are:

http://www.sqlteam.com/item.asp?ItemID=5403
http://www.codeproject.com/database/serverenum.asp
http://support.microsoft.com/kb/q287737/

If you do figure this out, I would appreciate if you would post your results
back to the news group.

Thanks

--
Martin Duty
IT Manager
Underground Vaults & Storage, Inc.
TD 3.0 PFT2
Client Win 2K/XP
Database MS Sql Server 2000

Martin Duty

Enumeration APP for SQL servers Driver

Post by Martin Duty » 03 Mar 2005, 15:27

 Posted by:  Martin Duty 

ok, a bit more and now I'm stuck. I never can understand this ActiveX stuff.
arrghhh...

FunctionalVar: adoNameList
Class: SQLDMO_NameList
FunctionalVar: adoApp
Class: SQLDMO__Application

Set bReturn = adoApp.CreateObject( 'SQLDMO.Database' )
Call adoApp.ListAvailableSQLServers( adoNameList )

bReturn returns TRUE. ListAvailableSQLServers gets a ActiveX error. shrug
sorry

--
Martin Duty
IT Manager
Underground Vaults & Storage, Inc.
TD 3.0 PFT2
Client Win 2K/XP
Database MS Sql Server 2000

Martin Duty

Enumeration APP for SQL servers Driver

Post by Martin Duty » 07 Mar 2005, 21:38

 Posted by:  Martin Duty 

ok, got it..... This should be what you are looking for.

--
Martin Duty
IT Manager
Underground Vaults & Storage, Inc.
TD 3.0 PFT2
Client Win 2K/XP
Database MS Sql Server 2000

Attachment: SQLSErverEnum.apt

Return to “advanced.programming”

Who is online

Users browsing this forum: [Ccbot] and 0 guests