help with sql server


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: help with sql server

  1. #1
    Join Date
    Jul 2005
    Posts
    1

    Question help with sql server

    hello,
    i need to connect to sql server on local machine
    with the local system account and list all the databases
    Does anyone have any idea how to do this with vb6 ?
    10x
    Last edited by abja; 07-11-2005 at 10:14 AM.

  2. #2
    Join Date
    Dec 2003
    Posts
    2,750
    One way is to use the ADO OpenSchema method:

    Code:
    Dim cnn As New ADODB.Connection
    Dim rs As New ADODB.Recordset
    Dim fld As ADODB.Field
    
    cnn.Open "Provider=sqloledb;" & _
               "Data Source=(local);" & _
               "Initial Catalog=master;" & _
                "Integrated Security=SSPI"
    
    Set rs = cnn.OpenSchema(adSchemaCatalogs)
    
    While Not rs.EOF
        For Each fld In rs.Fields
            Debug.Print fld.NAME & ": " & fld.Value
        Next fld
        rs.MoveNext
    Wend
    
    cnn.Close
    Paul
    ~~~~
    Microsoft MVP (Visual Basic)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center