-
Some please help me!!!
I cannot get my bound datagrid to update once I have updated
the datagrid and clicked a save button. Here is my code, someone please help.
Private Sub adminForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
AdjustStockDtgLoad()
End Sub
Private Sub AdjustStockDtgLoad()
Dim sqlQuery As String = "select * from stockLevels"
stockLevelsDataSet.Clear()
adminDataAdapter.SelectCommand.CommandText = sqlQuery
adminDataAdapter.Fill(stockLevelsDataSet, "stockLevels")
Dim dataTable As DataTable = stockLevelsDataSet.Tables(0)
dtgAdjStockLevel.SetDataBinding(stockLevelsDataSet, "stockLevels")
End Sub
Private Sub cmdAdjSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdjSave.Click
Try
adminDataAdapter.Update(stockLevelsDataSet, "stockLevels")
dtgAdjStockLevel.Enabled = False
Catch ex As System.Data.OleDb.OleDbException
MsgBox(ex.ToString())
End Try
End Sub
-
Just to clarify what exactly I mean. I have managed to bind a datagrid from a dataAdapter. T
he data loads in fine.
When the Data is in the table I want to edit the cells and update the original access database uppon click of a save command.
-
I'm still not sure how this works or if it's the right solution, but it worked for me.
Add the following statement before your update:
dim aCommandBuilder as new OleDbcommandBuilder(adminDataAdapter)
You can look at documentation for OleDbCommandBuilder for explanation.