i have a program with 4 datagridviews and im populating them with the following code:
Private Sub Admin_Load(sender As Object, e As EventArgs) Handles MyBase.Load
CodeMonkey.adminview(InfoDG, "[Info]")
CodeMonkey.adminview(RoomDG, "[Rooms]")
CodeMonkey.adminview(UserDG, "[Logins]")
CodeMonkey.adminview(SettingsDG, "[Monkey]")
End Sub
this is for the form loader, then we have the sub that's being called.
Public Sub adminview(ByVal dgv As DataGridView, ByVal Table As String)
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM " & Table & "", con)
con.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(da)
Dim ds As DataSet = New DataSet
da.Fill(ds, Table)
con.Close()
dgv.DataSource = ds.Tables(Table).DefaultView
dgv.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
End Sub
the datagridviews are populating properly and working fine, my issue comes when i want to update the information, how can i set update.
What I have tried:
Originally i had the codes separated for each DGV so i have declared a name for each dataset and other items, so the update was as just useing the command DA.update(DS,Table). but now i dont know the name that holding it. i also tried with the following Sub
Public Sub updater(ByVal Table As String)
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM " & Table & "", con)
con.Open()
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Dim builder As OleDbCommandBuilder = New OleDbCommandBuilder(da)
Dim ds As DataSet = New DataSet
da.Update(ds, Table)
ds.AcceptChanges()
con.Close()
End Sub
this didnt work however