G
Guest
hello,
I have put thisup b4, but I think that people have misunderstood the problem, so I will make it clearer.
I have a problem updating a dataset that is bound to a datagrid.
The code that I use to set up the grid dgsimple to the dataset Mydataset and the table "Orders" is as below (see bottom of page)
My problem is that I can change data in the datagrid on the first row of the grid and the changes will be immediately written away, However If I change data on the 2nd or subsequent rows the data is not written away until you click on the next row of the grid, and you can't expect users to always click on the next row.
What am I doing wrong, Does the bindingcontext have to specify the exact row of the dataset and just defaults to row 0 if none is specifeld. Please help
Geraldine
Private Sub SetupGrid()
'Fill the DataSet
Dim Mycon As SqlConnection = New SqlConnection(strconn)
Dim strquery As String
strquery = "Exec spOrders " & 402
MySqlDataadapter = New SqlDataAdapter(strquery, Mycon)
MyDataset = New DataSet
MySqlDataadapter.FillSchema(MyDataset, SchemaType.Source, "Orders")
MySqlDataadapter.Fill(MyDataset, "Orders")
Mycon = Nothing
End Sub
Private Sub FormatOrdersGrid()
dgsimple.DataSource = MyDataset
dgsimple.DataMember = "Orders"
dgsimple.SetDataBinding(MyDataset, "Orders")
End Sub
Private Sub dgsimple_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgsimple.CurrentCellChanged
DirectCast(BindingContext(MyDataset.Tables!Orders), CurrencyManager).EndCurrentEdit()
Dim objCommandBuilder As New SqlCommandBuilder(Mysqldataadapter)
MySqlDataadapter.Update(MyDataset, "Orders")
End Sub
I have put thisup b4, but I think that people have misunderstood the problem, so I will make it clearer.
I have a problem updating a dataset that is bound to a datagrid.
The code that I use to set up the grid dgsimple to the dataset Mydataset and the table "Orders" is as below (see bottom of page)
My problem is that I can change data in the datagrid on the first row of the grid and the changes will be immediately written away, However If I change data on the 2nd or subsequent rows the data is not written away until you click on the next row of the grid, and you can't expect users to always click on the next row.
What am I doing wrong, Does the bindingcontext have to specify the exact row of the dataset and just defaults to row 0 if none is specifeld. Please help
Geraldine
Private Sub SetupGrid()
'Fill the DataSet
Dim Mycon As SqlConnection = New SqlConnection(strconn)
Dim strquery As String
strquery = "Exec spOrders " & 402
MySqlDataadapter = New SqlDataAdapter(strquery, Mycon)
MyDataset = New DataSet
MySqlDataadapter.FillSchema(MyDataset, SchemaType.Source, "Orders")
MySqlDataadapter.Fill(MyDataset, "Orders")
Mycon = Nothing
End Sub
Private Sub FormatOrdersGrid()
dgsimple.DataSource = MyDataset
dgsimple.DataMember = "Orders"
dgsimple.SetDataBinding(MyDataset, "Orders")
End Sub
Private Sub dgsimple_CurrentCellChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgsimple.CurrentCellChanged
DirectCast(BindingContext(MyDataset.Tables!Orders), CurrencyManager).EndCurrentEdit()
Dim objCommandBuilder As New SqlCommandBuilder(Mysqldataadapter)
MySqlDataadapter.Update(MyDataset, "Orders")
End Sub