Results 1 to 6 of 6

Thread: [VB6] - Connect an Ms access 2010 dbase to a VB6 project issue

Hybrid View

  1. #1
    Member
    Join Date
    Aug 09
    Posts
    61

    [VB6] - Connect an Ms access 2010 dbase to a VB6 project issue

    I used to use this code bellow for accessing an access 2007 dbase but it looks like 2010 is not the same.
    I'm also on windows 7 64

    I have this error:
    Runtime Error 3709
    The Connection Cannot be used to perform this kind of operation.
    it is either closed or invalid in this context

    I think the issue is with this part of the code but i dont know why:
    Code:
    oRST1.Open Conns, Conn
    Can you please help me?

    Thanks again

    Code:
    Dim Conn As ADODB.Connection
    Dim Conns As String
    Dim oRST1 As ADODB.Recordset
    Set oRST1 = New ADODB.Recordset
      
    Set Conn = New ADODB.Connection
    Conns = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & Form2.txtBaseDelabsolution.Text
    Conn.ConnectionString = Conns
    'Conn.Open
    nom.AddItem ""
    oRST1.Open Conns, Conn
    Do Until oRST1.EOF
      nom.AddItem oRST1("Nom")
      oRST1.MoveNext
    Loop
    Last edited by wilder1926; Aug 17th, 2012 at 03:58 PM.

  2. #2
    Frenzied Member
    Join Date
    May 06
    Location
    some place in the cloud
    Posts
    1,634

    Re: [VB6] - Connect an Ms access 2010 dbase to a VB6 project issue

    The error is clear enough, the connection is closed
    You have the line commented
    'Conn.Open
    JG


    ... If your problem is fixed don't forget to mark your threads as resolved using the Thread Tools menu ...

  3. #3
    Member
    Join Date
    Aug 09
    Posts
    61

    Re: [VB6] - Connect an Ms access 2010 dbase to a VB6 project issue

    Hi jggtz

    Sorry, that was one of my test.
    If i do
    Code:
    Conn.Open
    i have the "Run time error 3706 Provider cannot be found, it may not be properly installed"

    Code:
    Dim Conn As ADODB.Connection
    Dim Conns As String
    Dim oRST1 As ADODB.Recordset
    Set oRST1 = New ADODB.Recordset
      
    Set Conn = New ADODB.Connection
    Conns = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & Form2.txtBaseDelabsolution.Text
    Conn.ConnectionString = Conns
    Conn.Open
    nom.AddItem ""
    oRST1.Open Conns, Conn
    Do Until oRST1.EOF
      nom.AddItem oRST1("Nom")
      oRST1.MoveNext
    Loop

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,568

    Re: [VB6] - Connect an Ms access 2010 dbase to a VB6 project issue

    Have you installed the 32-bit version of ACE?

    You can download it via the link in my signature, but be warned that you cannot have the 32-bit version and the 64-bit version installed at the same time, so if the 64-bit version is needed by any other program you will have lots of work to do just to be able to use your program (or the other) each time.

  5. #5
    Frenzied Member
    Join Date
    Jan 09
    Location
    Watch Window(Shift+f9)
    Posts
    1,431

    Re: [VB6] - Connect an Ms access 2010 dbase to a VB6 project issue

    Can you try the following way ? as you have missed the set Keyword.
    Code:
    Dim Conn As ADODB.Connection
    Dim Conns As String
    Dim oRST1 As ADODB.Recordset
    Set oRST1 = New ADODB.Recordset
      
    Set Conn = New ADODB.Connection
    Conns = "Provider=Microsoft.ACE.OLEDB.12.0;" & "Data Source=" & Form2.txtBaseDelabsolution.Text
    set Conn.ConnectionString = Conns
    Conn.Open
    nom.AddItem ""
    oRST1.Open Conns, Conn
    Do Until oRST1.EOF
      nom.AddItem oRST1("Nom")
      oRST1.MoveNext
    Loop

  6. #6
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 02
    Location
    Bristol, UK
    Posts
    35,568

    Re: [VB6] - Connect an Ms access 2010 dbase to a VB6 project issue

    Set is not valid, because .ConnectionString is not an object (it is a String).

Posting Permissions

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