I have no problems adding, deleting or editing data from a database when
these functions are on the 1st form. I need these functions on the 2nd form
though, as the 1st form will be a Menu screen.
Public Class Form2
Inherits System.Windows.Forms.Form
Dim con As String = "Provider = Microsoft.Jet.OLEDB.4.0;Data Source =
C:\TravelAgents.mdb"
Dim sqlStr As String = "SELECT * FROM Members"
Dim oleDbMembersAdapter As New OleDb.OleDbDataAdapter(sqlStr, con)
Dim oDataTable As New DataTable
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
oleDbMembersAdapter.Fill(oDataTable)
End Sub
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
Dim MyNewRow As DataRow = oDataTable.NewRow
Dim changes As Integer
Dim commandbuilder As New OleDb.OleDbCommandBuilder(oleDbMembersAdapter)
MyNewRow("Forename") = txtForename.Text
oDataTable.Rows.Add(MyNewRow)
changes = oleDbMembersAdapter.Update(oDataTable)
MsgBox("Sucess")
End Sub
End Class
This however does not work when i try to add off the 2nd form highlighting
'changes = oleDbMembersAdapter.Update(oDataTable)' as a problem. The only
code on the 1st form is the btnNext code, only a navigational button. Would
I need anymore code on form 1 or form 2 (above).
|