D
di
I am new to VB.NET and having some problem with the data binding for
controls. My problem is this:
I want to create a form that has a number of textboxes that relate to fields
in a SQL table. When I update the textboxes, I want SQL to be updated (by
pressing an update button).
I have now read various articles in various books and seem to be getting
nowhere, even when I am creating a test.
My test form has three textboxes, a data adapter ("clientadapter" - added by
the wizard), a "clientconnection" (added by the wizard) and I have generated
a dataset "clientdataset". The connection and adapter is connecting to
Northwind and getting "Select * from Customers".
Each of the textboxes have had the "DataBindings Text" property set to an
appropriate field from the "clientdataset".
On loading the form i run
clientAdapter.fill(clientDataset)
which happily populates the textboxes with information from the database.
I also have a button on the form called btnUpdate, the code behind which is:
clientAdapter.Update(clientDataset)
I was expecting that this update code would go and update the actual
database, however, when I close the application and run it again, the
changes that I have made to the fields are lost.
I am certain that I am missing something fairly simple, but i cannot find it
for the life of me.
I would be very grateful if someone could help me out.
Many thanks
DI
PS: Strangely, when I bind a datagrid to the dataset, the update facility
works as I would expect. It only seems to be causing a problem with the
textboxes.
controls. My problem is this:
I want to create a form that has a number of textboxes that relate to fields
in a SQL table. When I update the textboxes, I want SQL to be updated (by
pressing an update button).
I have now read various articles in various books and seem to be getting
nowhere, even when I am creating a test.
My test form has three textboxes, a data adapter ("clientadapter" - added by
the wizard), a "clientconnection" (added by the wizard) and I have generated
a dataset "clientdataset". The connection and adapter is connecting to
Northwind and getting "Select * from Customers".
Each of the textboxes have had the "DataBindings Text" property set to an
appropriate field from the "clientdataset".
On loading the form i run
clientAdapter.fill(clientDataset)
which happily populates the textboxes with information from the database.
I also have a button on the form called btnUpdate, the code behind which is:
clientAdapter.Update(clientDataset)
I was expecting that this update code would go and update the actual
database, however, when I close the application and run it again, the
changes that I have made to the fields are lost.
I am certain that I am missing something fairly simple, but i cannot find it
for the life of me.
I would be very grateful if someone could help me out.
Many thanks
DI
PS: Strangely, when I bind a datagrid to the dataset, the update facility
works as I would expect. It only seems to be causing a problem with the
textboxes.