I'm currently using system.data.oledb but I can't seem to make the update , search, & delete work fine. Are there any other ways on how to manipulate an ms access database in vb.net easier than my method? Here is my code for searching:
Dim cn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=F:\ACCESS DATABASE\search.mdb")
Dim cmd As OleDbCommand = New OleDbCommand("Select * from GH where IDNUMBER= '" & TextBox12.Text & "' ", cn)
cn.Open()
Dim rdr As OleDbDataReader
rdr = cmd.ExecuteReader
If rdr.HasRows Then
rdr.Read()
NoAcc = rdr("IDNUMBER")
If (TextBox12.Text = NoAcc) Then TextBox13.Text = rdr("NAME")
If (TextBox12.Text = NoAcc) Then TextBox14.Text = rdr("DEPARTMENT")
If (TextBox12.Text = NoAcc) Then TextBox15.Text = rdr("COURSE")
Then you will have to make the necessary changes before pressing update: This is the update code, which is defective(it really updates the data but then it will duplicate the previous data, and the updated data will have a different id number):
Dim cb As New OleDb.OleDbCommandBuilder(da)
ds.Tables("GH").Rows(INC).Item("NAME") = TextBox13.Text
ds.Tables("GH").Rows(INC).Item("DEPARTMENT") = TextBox14.Text
ds.Tables("GH").Rows(INC).Item("COURSE") = TextBox15.Text
da.Update(ds, "GH")
开发者_开发技巧 MsgBox("Data updated")
you can use this one for the update
If nameoftable.Rows.Count <> 0 Then
nameoftable.Rows(recordposition)("course_code") = textbox1.Text
nameoftable.Rows(recordposition)("course_description") = textbox2.Text
nameofyouradapter.Update(nameoftable)
End If
You can call DAO code through com interop in vb.net. The DAO interface is designed to work with the JET database engine directly so in most cases offers better performance than using ado.net or ADO however it does tie you into JET to some degree.
精彩评论