Updating database with dataset

Set the following properties for your buttons: Name: btn Add New Text: Add New Name: btn Save Text: Save Enabled: False Name: btn Cancel Text: Cancel Enabled: False The Add New button won't actually add a new record. We need to do this because the textboxes are all blank. The textboxes will go blank, and the first record will disappear. You need to do it this way because the Dataset with its copy of the records is disconnected from the database. We'll be updating the database with these new changes. At the end, in between round brackets, we have the name of our Data Adapter, which was da_1. This property has a method of its own called Update.

The inc variable can be set to the last record in the Dataset, which is Max Rows - 1. Enabled = true; These three lines just reset the buttons to their original state. Either loads a table or creates it if it doesn’t exist yet.You can define the name and type of the primary key field, if a new table is to be created.The final three lines of our Save code are these: btn Cancel. The whole of the code for your Save button should look like this: Try it out.When you start your programme, click the Add New button to clear the textboxes. When you close down your project and open it up again, the new record should still be there.

Leave a Reply