Results 1 to 3 of 3

Thread: connectivity of vb6with MS-Access

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2002
    Location
    india
    Posts
    1

    connectivity of vb6with MS-Access

    how can we connect with ms-access?

  2. #2
    champgary
    Guest
    It can be in this way
    <vbcode>
    Public conn As ADODB.Connection
    Public rsWord As ADODB.Recordset
    Set conn = New Connection
    With conn
    .Provider = "Microsoft.Jet.OLEDB.4.0"
    ' or you can use 3.51 also
    .ConnectionString = App.Path & "\YourDatabase.mdb"
    ' specify path if database not located in project directory and then mdb name
    .Open
    End With

    Set rsWord = New Recordset
    If rsWord .State = adStateOpen Then rsWord .Close
    rsWord .Open "Select * from employee ", conn, adOpenKeyset, adLockOptimistic
    txtempno = rsWord !empno ' or rsGmHira.Fields(0) like that
    </vbcode>

    Regards
    Gary

  3. #3
    Frenzied Member John McKernan's Avatar
    Join Date
    Jan 2002
    Location
    SE PA
    Posts
    1,295
    Just to expand on champgary's information a little:

    1. For this code to work you will need to set a reference (Project | References) to Microsoft ActiveX Data Objects 2.x
    2. This provider string: .Provider = "Microsoft.Jet.OLEDB.4.0" is appropriate for Access 2000 mdb's
    3. You can use this provider string: .Provider = "Microsoft.Jet.OLEDB.3.51" for Access97

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