CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: ADO

  1. #1
    Join Date
    Jun 2001
    Posts
    5

    ADO

    I wanted to attached .mdb file through programme using ADO. How do I?


  2. #2
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Re: ADO

    Well, i've never tried to connect to an mdb file using ADO (that's really what DAO is for), but according to a big book i paid a lot of money for, ADO can't handle the MS Jet Database format... otherwise known as Access mdb files. That just doesn't seem cool though, I'll keep lookin around to see if this has changed since this book was published.


  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: ADO

    For Standard Security:
    Code:
    oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ 
                       "Dbq=\somepath\mydb.mdb;" & _
                       "Uid=Admin;" & _
                       "Pwd=;"
    If you are using a Workgroup (System database):
    Code:
    oConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _ 
                       "Dbq=\somepath\mydb.mdb;" & _
                       "SystemDB=\somepath\mydb.mdw;", _
                       "admin", ""
    'latest and greatest
    Code:
    sConn =  "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Data Source=" & DBNAME  & _
            ";Persist Security Info=False"
    Persist Security Info is important when db is password protected (False  eliminate pwd protection?)
    '===================================================================
    Code:
    'connection to secure database
    Dim Cnn As ADODB.Connection
    Dim Rst As ADODB.Recordset
    
    'In the place where you want to establish your connection, such 
    'as the Initialize event of a class module, enter the following:
    
    Dim strConnect As String
    Set Cnn = New ADODB.Connection
    
    'Substitute your own User IDs, Password, Data Source, and System
    'database in the connection string below
        strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
            "Password=MyPassword;User ID=Administrator;" & _
            "Data Source=C:\AccessDBs\DB1.mdb;" & _
            "Persist Security Info=True;" & _
            "Jet OLEDB:System database=C:\AccessDBs\system.mdw"
    
        With Cnn
            .CursorLocation = adUseClient
            .Open strConnect
        End With
        
        Set Rst = New ADODB.Recordset
        Rst.ActiveConnection = Cnn
    Iouri Boutchkine
    [email protected]
    Last edited by Cimperiali; July 16th, 2006 at 03:22 PM. Reason: Adding code tags
    Iouri Boutchkine
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured