emaduddeen
Well-known member
- Joined
- May 5, 2010
- Messages
- 171
- Location
- Lowell, MA & Occasionally Indonesia
- Programming Experience
- Beginner
Hi Everyone,
I'm using the book titled "Database Programming with Visual Basic® .NET and ADO.NET: Tips, Tutorials, and Code".
I'm going through the chapter that has me do data binding by setting the properties of a DataGrid and TextBoxes.
It had me drag a DataAdapter onto the form using the wizard and had me generate a DataSet. This part works fine. It also had me set the binding through the Text propert of each TextBox. This also works fine as it displays the correct data as the user navigates through the DataGrid.
I think there may be something missing from the code samples in the book because saving the data back to the database is not working and even no errors are reported.
Here is the code from the book that writes changed text in the TextBoxes back to SQL Server. Can you tell me what the book is missing?
Thanks.
Truly,
Emad
I'm using the book titled "Database Programming with Visual Basic® .NET and ADO.NET: Tips, Tutorials, and Code".
I'm going through the chapter that has me do data binding by setting the properties of a DataGrid and TextBoxes.
It had me drag a DataAdapter onto the form using the wizard and had me generate a DataSet. This part works fine. It also had me set the binding through the Text propert of each TextBox. This also works fine as it displays the correct data as the user navigates through the DataGrid.
I think there may be something missing from the code samples in the book because saving the data back to the database is not working and even no errors are reported.
Here is the code from the book that writes changed text in the TextBoxes back to SQL Server. Can you tell me what the book is missing?
VB.NET:
Private Sub SaveRecord()
' Use the BindingContext class to end current editing so that we can update the server.
'--------------------------------------------------------------------------------------
BindingContext(DataSetCustomerIndividual, "Customers").EndCurrentEdit()
' Perform the requested task at the dataset level using the data adapter.
'------------------------------------------------------------------------
SqlDataAdapterCustomerIndividual.Update(DataSetCustomerIndividual, "Customers")
' By accepting the changes, the data gets sent back to the server.
'-----------------------------------------------------------------
DataSetCustomerIndividual.AcceptChanges()
End Sub
Thanks.
Truly,
Emad