Question : 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!
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
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

Answer : VB program connecting to Access DB - arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

Random Solutions  
 
programming4us programming4us