Interview Tips Interview Tips, Interview Questions and Answers

11Jul/100

How to save data from dataset?

The modified data needs to be sent back to the database in order to save it. Therefore, to send the modified data to a database, the Update method of a TableAdapter or data adapter needs to be called. The Update method executes either of INSERT, UPDATE, or DELETE depending on the RowState in the table.

In Visual Studio a TableAdapterManager component is used for saving the proper order based on the foreign-key constraints of the database.

Although the procedure to save the data may change depending upon the applications, the following steps throw light on the generalized concept:

The code sends updates to the database should be written within a try/catch block.

The data row should be located to determine the problem area and the code should then be reattempted.