RocAFella2007
Technical User
Hi, Im new to vb if anyone finds the way i talk confusing then im sorry. Could somebody please 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 in the datagrid. 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 automatically in the datagrid, 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:
The above retrieves the details, but I need help on updating.
So far I have tried:
I have also tried
This is really frustrating me so if anybody could help me out or even suggest anything I would really appreciate it.
Thanks in advance!!
So far to retrieve the details for the datagrid, I Have:
Code:
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
So far I have tried:
Code:
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
Code:
Dim adapter As New OleDbDataAdapter
Dim dt As New DataTable("Contacts")
adapter.Update(dt)
This is really frustrating me so if anybody could help me out or even suggest anything I would really appreciate it.
Thanks in advance!!