Click to See Complete Forum and Search --> : Some please help me!!!


scottie_uk
May 3rd, 2003, 01:50 PM
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

scottie_uk
May 3rd, 2003, 04:05 PM
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.

wpilcher
May 4th, 2003, 10:36 PM
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.