Folks:
I am trying to establish a connection with an Access DB. To me the code looks right..but I get an error in the da.Fill(ds,"table1") and the error is
"Fill select.command.connection property has not been initialized".. i know it means that the connection has not been established properly but i dont see how..it will be very helpful if u helped me understand where I am going wrong in my code.
thanks
kukki.
Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
Dim con As New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
Dim cmd1 As New OleDbCommand
con.Open()
If (CheckBox1.Checked = True) Then
cmd1 = New OleDbCommand("select * from table1 where RAM='< 2 GB'", con)
End If
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd1)
Try
Dim ds As DataSet = New DataSet()
da.Fill(ds, "table1")
DataGridView1.DataSource = ds.Tables("table1").DefaultView
Finally
con.Close()
cmd1 = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub