Update the database from the data set

zhaozj2021-02-16  46

DataSet can be treated as the memory cache of data from the database. DataSet consists of a collection of tables, relationships, and constraints.

Private system.data.sqlclient.sqldataAdapter SqlDataAdapter1;

Private system.data.sqlclient.sqlConnection SqlConnection1;

private System.Data.DataSet dataset = new DataSet (); private System.Data.DataRow datarow; private System.Data.SqlClient.SqlCommandBuilder sqlcommandbuilder = new SqlCommandBuilder (sqlDataAdapter1); // commit the changes back to the database before, we need to set the InsertCommand, UpdateCommand and DeleteCommand are coordinated to make changes to the database. For a limited solution, these commands can be automatically generated using SQLCommandBuilder.

sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapte (mySqlString, sqlConnection1); sqlDataAdapter1.Fill (dataset, "ly");. datarow = dataset.Tables [ "ly"] NewRow (); datarow [ "name"] = " "; DATAROW [" Title "] =" fool "; DATAROW [" text "] =" dlfajd "; dataset.tables [" ly "]. Rows.add (DataRow); SqlDataAdapter1.Update (Dataset," LY " );

As for the database update dataset (Dataset) is easy:

String selectcmdstring = "select * from customer mysqldataadapter = new sqldataadapter (selectcmdstring, myconnection);

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

New Post(0)