Link to home
Start Free TrialLog in
Avatar of Wilder1626
Wilder1626Flag for Canada

asked on

Connect an Ms access 2010 dbase to a VB6 project issue

Hello all

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:
oRST1.Open sSQL1, oConnect1

Open in new window


Can you please help me?

Thanks again

Dim sSQL1 As String
  Dim oConnect1 As ADODB.Connection
  Set oConnect1 = New ADODB.Connection
  Dim oRST1 As ADODB.Recordset
  Set oRST1 = New ADODB.Recordset


sSQL1 = "SELECT DISTINCT[nom]FROM [Clients]'"

oConnect1 = "Provider=Microsoft.ACE.OLEDB.12.0;" & _
"Data Source=" & Form2.txtBaseDelabsolution.Text

nom.AddItem ""
oRST1.Open sSQL1, oConnect1
Do Until oRST1.EOF
  nom.AddItem oRST1("Nom")
  oRST1.MoveNext
Loop

Open in new window

Avatar of Wilder1626
Wilder1626
Flag of Canada image

ASKER

I have just tried like this and same issue:
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

Open in new window

I tried also like this but now, i have "Run time error 3706 Provider cannot be found, it may not be properly installed"


im 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

Open in new window

The fastest was to solve this is to install Just Access 2003 from an office CD in compatibility mode the you can open the database in VB6 as if you were running on XP or Win 7 32 bit.

Or see this post on Microsoft.com:

http://answers.microsoft.com/en-us/windows/forum/windows_7-windows_programs/msjet40-on-win7-64bit-cant-find-providers/848b8ce9-3f92-491b-8f28-4e3927e5fdb7?msgId=e1b9ad55-026e-4811-9fad-de0686431883
.
But once the project compiled, will it work on another PC with windows 7 and Access 2010? or will i have to again install Access 2003 in compatibility mode?
SOLUTION
Avatar of inthedark
inthedark
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
are you running in compatibility mode?
Hello all

No, not yet, I,m wondering if i should stay with office 2007 or switch to 2010.

I was looking on the web for the compatibility mode and they just talk about Excel, Word and PowerPoint. Not access.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks again for your help. For now, i will stay with Office 2007 and work for another solution after.