Friday, February 24, 2012

Browse through a list of databases on a given server

Hi,
I would like to allow the user of my ADO.NET application to browse through a list of the available databases on a given server. INFORMATION_SCHEMA in SQL Server Books Online doesn't describe how to do this. How can I do this?
TIA,
RoyceSELECT * FROM master..sysdatabases|||In VB6,use traditional adodb object.We can get any level schema infomation of sql server by OpenSchema method.
I pasted VB6 sample codes ,hope it should be helpful to u.

example:
Dim cn As New ADODB.Connection
Dim rs As ADODB.Recordset

cn.Open "Provider=SQLOLEDB.1;Password="""";Persist Security Info=True;User ID=sa;Data Source=wmcw"
Set rs = cn.OpenSchema(adSchemaCatalogs)

Do While Not rs.EOF
Debug.Print rs.Fields("CATALOG_NAME").Value & vbTab & rs.Fields("DESCRIPTION").Value
rs.MoveNext
Loop

No comments:

Post a Comment