Hi, thanks for the reply but I am getting a little stuck. As I am so new to this I don't have a clue really of what does what and I am trying to merge your code with what I am being taught and getting an error. This is what I have so far:
Code:
Dim dbRec As New ADODB.Recordset
Dim dbObj As New ADODB.Connection
Form Load:
Code:
ConnectDB(strDatabasePath & "Data.mdb")
Dim CMD As New ADODB.Command
With CMD
.CommandText = "Select col1,col2,col3,col4 FROM table"
.CommandType = CommandType.Text
End With
'assign select command to data adapter
dbObj.SelectCommand = CMD
Dim dt As New DataTable("table")
dbObj.Fill(dt)
datagridview.DataSource = dt
ConnectDB Routine:
Code:
Private Sub ConnectDB(ByVal Database As String)
Dim intErr As Integer
Database = "Driver={Microsoft Access Driver (*.mdb)};Dbq=" & Database & ";DefaultDir=" & Database
dbObj.Open(Database)
Me.Show()
Call frmSuppliers_Load(Nothing, Nothing)
End If
End Sub
I have edited certain bits to replace column names and table name.
The error is happening on the line:
dbObj.SelectCommand = CMD
The Error:
No named arguments. (Exception from HRESULT: 0x80020007 (DISP_E_NONAMEDARGS))
Is there something that is coded wrong because I really don't have a clue what I am doing here lol.
Thanks,
Max