lcha
asked on
VB program connecting to Access DB - arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Hello experts,
I am learning how to write a program in Visual Studio 2008, using visual basic .net and ADO (referencing Microsoft Active X Data Objects 2.8 Library).
Using the code below, it fails at the line where I set a recordset's .source value to a sql string (see code below)
The error I'm getting is " arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Pls advise if you can see the issue here. Thanks in advance!
I am learning how to write a program in Visual Studio 2008, using visual basic .net and ADO (referencing Microsoft Active X Data Objects 2.8 Library).
Using the code below, it fails at the line where I set a recordset's .source value to a sql string (see code below)
The error I'm getting is " arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.
Pls advise if you can see the issue here. Thanks in advance!
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim strSQL As String
cn.Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Documents and Settings\Administrator\My Documents\testdb.accdb")
strSQL = "SELECT * FROM table1;"
With rs
.ActiveConnection = cn
.Source = strSQL
.Open()
End With
rs.Open()
If rs.EOF = False Then
rs.MoveFirst()
End If
Do
MsgBox(rs.Fields("Field1"))
rs.MoveNext()
Loop Until rs.EOF = True
cn.Close()
cn = Nothing
rs = Nothing
Is there a reason why you are calling Open() twice on the RecordSet? Once within the "With" and once just after it.
ASKER
You can please disregard the calling of open twice ... it's not like that in the current code.
Also, I am using Access 2007, so the database extension is correct ... .accdb
thanks
Also, I am using Access 2007, so the database extension is correct ... .accdb
thanks
ASKER
raising points on this
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
great, appreciate this. I'll continue working on this tommorrow and keep you posted. thanks.
ASKER
thank you! I got it working now!
cn.Open("Provider=Microsof
You should have this:
cn.Open("Provider=Microsof
jppinto