Provider =

G

Guest

I am new to ADO programming , having trouble getting a connection string to
operate properly

the following code generates an error stating that the provider could not be
found and may not be installed properly. I have visual studio running on the
same laptop and the provider string does not generate a problem. Is this a
reference problem?

Dim strSQL as String
Dim cnnName as New ADOB.Connection
Dim rs as New ADOB.Recordset

With cnnName
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open CurrentProject.Path & "\MyFilePath.mdb","Admin",-1
End With

strSQL = "Select * From tblEmployees"

With rs
.ActiveConnection = cnnName
.CurserType = AdOpenKeySet
.LockType = adLockOptimistic
.Open strSQL
End With

more code
 
J

Justin Hoffman

OldEnough said:
I am new to ADO programming , having trouble getting a connection string to
operate properly

the following code generates an error stating that the provider could not
be
found and may not be installed properly. I have visual studio running on
the
same laptop and the provider string does not generate a problem. Is this a
reference problem?

Dim strSQL as String
Dim cnnName as New ADOB.Connection
Dim rs as New ADOB.Recordset

With cnnName
.Provider = "Microsoft.Jet.OLEDB.4.0"
.Open CurrentProject.Path & "\MyFilePath.mdb","Admin",-1
End With

strSQL = "Select * From tblEmployees"

With rs
.ActiveConnection = cnnName
.CurserType = AdOpenKeySet
.LockType = adLockOptimistic
.Open strSQL
End With

more code



Do you know that you should try to compile your code before running it? If
it compiles, then you know there are no really basic mistakes. While
looking at your code, select Debug>Compile and that will start to pick out a
couple of things:

ADOB.Connection should be ADODB.Connection
..CurserType should be .CursorType

This moves you forward a bit, but what it won't find is the fact that you
have not supplied a password - you could have written
..Open CurrentProject.Path & "\MyFilePath.mdb"
..Open CurrentProject.Path & "\MyFilePath.mdb","Admin"
..Open CurrentProject.Path & "\MyFilePath.mdb","Admin",""
..Open CurrentProject.Path & "\MyFilePath.mdb","Admin","",-1
ie you don't need to supply any of the default parameters, but if you want
to supply the -1 at the end, you must supply a blank password or at least
provide more commas so the arguments are:
ConnectionString, UserID, Password, Options
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top