Hi. I want to retrieve data from access to datagrid using the code below, but it just doesn't work. I'm using visual studio 2010 and access 2007.
Private Sub Form2_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Dim con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\rex\Desktop\vbsample\vbdatabase.mdb")
con.open()
Dim q = New OleDbCommand("select * from information", con)
Dim info = New OleDbDataAdapter()
info.SelectCommand = q
info.Fill(DataSet1, "information")
grid.DataSource = DataSet1
con.close()
End Sub
BTW, DataSet1 is the name of my dataset component. I assume that it is similar with this:
Dim DataSet1 As Dataset = new Dataset
Private Sub Form2_Activated(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Activated
Dim con = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\rex\Desktop\vbsample\vbdatabase.mdb")
con.open()
Dim q = New OleDbCommand("select * from information", con)
Dim info = New OleDbDataAdapter()
info.SelectCommand = q
info.Fill(DataSet1, "information")
grid.DataSource = DataSet1
con.close()
End Sub
BTW, DataSet1 is the name of my dataset component. I assume that it is similar with this:
Dim DataSet1 As Dataset = new Dataset