|
-
May 3rd, 2003, 01:50 PM
#1
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
-
May 3rd, 2003, 04:05 PM
#2
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.
-
May 4th, 2003, 10:36 PM
#3
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|