This works for vb2005, and i belive vb.net also.
add this above you class declaration:
-
Imports System.Data.OleDb
-
THis code allows you to update tables and records etc:
Just change commandtext and source etc:
-
Dim StrConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Users\Users.mdb"
-
Dim oConn As New System.Data.OleDb.OleDbConnection(StrConn)
-
Dim con As New System.Data.OleDb.OleDbCommand
-
con.Connection = oConn
-
con.CommandType = CommandType.Text
-
con.CommandText = "insert into tblusers (FirstName,LastName,Login,[Password], Passwordchanged) values (" & "'" & txtFirstName.Text & "'," & "'" & txtLastName.Text & "'," & "'" & txtLogin.Text & "'," & "'" & txtPassword.Text & "'," & "'" & strdate & "')"
-
'add("insert into tblusers (FirstName,LastName,Login,[Password], Passwordchanged) values (" & "'" & "c" & "'," & "'" & "c" & "'," & "'" & "c" & "'," & "'" & "c" & "'," & "'" & strdate & "')")
-
'"Update TBLUsers set [login] = " & "'" & "NEW" & "'" & " where [FirstName] = " & "'" & "ab" & "'"
-
oConn.Open()
-
con.ExecuteNonQuery()
-
oConn.Close()
-
This allows you to query the table
-
Dim StrConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\Users\Users.mdb"
-
Dim oConn As New System.Data.OleDb.OleDbConnection(StrConn)
-
Dim da As System.Data.OleDb.OleDbDataAdapter
-
Dim oDS As New System.Data.DataSet
-
Dim strSQL As String = "Select * From tblUsers"
-
da = New OleDbDataAdapter(strSQL, oConn)
-
da.Fill(oDS, "Table1")
-
DGV1.DataSource = oDS.Tables("Table1").DefaultView
-
DGV1.Refresh()
-
da = Nothing
-
oDS = Nothing
-
oConn = Nothing
-
Cheers James