Update the database about using dbdataadapter.update method

xiaoxiao2021-03-06  64

DBDataAdapter When calling the Update method, DataAdapter analyzes the made changes and performs the corresponding command (INSERT, UPDATE, or DELETE). When DataAdapter encounters changes to DataRow, it will use INSERTCOMMAND, UPDATECMMAND, or DELETECOMMAND to process the change. This way, you can use the stored procedure to improve the performance of the ADO.NET application by specifying a command syntax when designing and possibly by using a stored procedure. These commands must be explicitly set before calling Update. If Update is called but there is no corresponding command for a particular update (for example, there is no deleteCommand for deleted rows), exceptions will be triggered. But if DataTable is mapped to a single database table or generated from a single database table, you can automatically generate DataApter's deleteCommand, InsertCommand, and UpdateCommand using the CommandBuilder object. To automatically generate commands, you must set the selectcommand property, which is the lowest requirements. SelectCommand retrieves the table architecture to determine the syntax of the automatically generated INSERT, UPDATE, and DELETE statements. If you modify SelectCommand's CommandText after you automatically generate insert, update, or delete commands, you may have an exception. If the architecture information contained in SELECTCOMMAND.COMMANDText is inconsistent with the selectcommand.CommandText used to automatically generate insert, update, or delete commands, the call to the DataAdapter.Update method will try to access the current table referenced by SelectCommand. The columns do not exist and will cause an exception. You can refresh the architecture information of the CommandBuilder to automatically generate the command by calling the Refreshschema method of CommandBuilder. Updating the database for DBDataAdapter.Update methods, each time you call DBDataAdapter.Update (DS), must do DS.ACCEPTCHANGES will otherwise an unexpected error on the DS used later. Depressed ~ Changed the procedure for a day, I found that it is this mistake, too depressed ~~

转载请注明原文地址:https://www.9cbs.com/read-111357.html

New Post(0)