Hi, I was wondering if somebody could help me out a little bit as im puzzled. Basically on a form I have a datagrid and some buttons, the buttons are simple and do simple operations. The part im struggling on at the moment is the 'Update' button, the only way I can update at the moment is if someone selects a record from the datagrid and clicks on the 'Edit' button, then another form appears with text boxes where users edit the data and it saves it back into the datagrid. However the help I require is updating records straight away within the datagrid when any record has been changed. For example when a user logs on, they see a datagrid and they change some recrods and select the update button I want the details to get updated already, I know about the OleDBDataadapter1.update(Dataset) method but I cant use that as I have coded my datagrid and not relied on the Wizard.
So far to retrieve the details for the datagrid, I Have:
Code:
The above retrieves the details, but I need help on updating.
So far Ive got to:
Any suggestions please? Thanks in advance!
So far to retrieve the details for the datagrid, I Have:
Code:
VB.NET:
Private Sub RetrieveContacts()
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & Application.StartupPath & "\AddressBook.mdb")
Dim adapter As New OleDbDataAdapter("Select * from Contacts", conn)
Dim dt As New DataTable("Contacts")
adapter.Fill(dt)
dgContacts.DataSource() = dt
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
RetrieveContacts()
End Sub
The above retrieves the details, but I need help on updating.
So far Ive got to:
VB.NET:
Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
Dim conn As New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=" & Application.StartupPath & "\AddressBook.mdb")
Dim adapter As New OleDbDataAdapter("Select * from Contacts", conn)
Dim dt As New DataTable("Contacts")
adapter.Update(dt)
dgContacts.DataSource() = dt
End Sub
Any suggestions please? Thanks in advance!