Loop All Database In Server

H

Henry C. Wu

Hi all,
I was wondering how can I loop through all the database in a
particular server using ADODB into a combobox? Below is the code I
tried using but didnt work, any hints/solutions for this anyone??

Thanks,
Henry


Dim Cnxn As ADODB.Connection
Dim rstSchema As ADODB.Recordset
Dim strCnxn As String

Cnxn = New ADODB.Connection

'Sybase ASE ODBC Driver Connection string - uses DSN
'strCnxn = "DSN=ase4141;UID=" & ;PWD=;"
strCnxn = "DSN=" & Me.cbxDataSource.Text & ";UID=" &
Me.tbxLogin.Text & ";PWD=" & Me.tbxPassword.Text

Cnxn.Open(strCnxn)

rstSchema = Cnxn.OpenSchema(ADODB.SchemaEnum.adSchemaSchemata)

Do Until rstSchema.EOF
Debug.WriteLine(rstSchema)
rstSchema.MoveNext()
Loop

' clean up
rstSchema.Close()
Cnxn.Close()
rstSchema = Nothing
Cnxn = Nothing
 
K

Ken Tucker [MVP]

Hi,

Maybe this will help.

http://www.informit.com/articles/article.asp?p=27199&redir=1

Ken
----------------
Hi all,
I was wondering how can I loop through all the database in a
particular server using ADODB into a combobox? Below is the code I
tried using but didnt work, any hints/solutions for this anyone??

Thanks,
Henry


Dim Cnxn As ADODB.Connection
Dim rstSchema As ADODB.Recordset
Dim strCnxn As String

Cnxn = New ADODB.Connection

'Sybase ASE ODBC Driver Connection string - uses DSN
'strCnxn = "DSN=ase4141;UID=" & ;PWD=;"
strCnxn = "DSN=" & Me.cbxDataSource.Text & ";UID=" &
Me.tbxLogin.Text & ";PWD=" & Me.tbxPassword.Text

Cnxn.Open(strCnxn)

rstSchema = Cnxn.OpenSchema(ADODB.SchemaEnum.adSchemaSchemata)

Do Until rstSchema.EOF
Debug.WriteLine(rstSchema)
rstSchema.MoveNext()
Loop

' clean up
rstSchema.Close()
Cnxn.Close()
rstSchema = Nothing
Cnxn = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top