-I am so lazy today when I work overtime. I am brewing a new project. I have not figured out the name, and the main functions are kept confidential. The progress is 30%. I have done a good job of releasing the original code, don't a brother in the circle simulate dos?
// -- Decompress sqlcommandbuilder sqlcommandbuilder1 = new sqlcommandbuilder (sqldataadapter1 );
// Initialize the sqlcommandbuilder instance with the sqldataadapter1 Parameter
Dsdataset1.tables ["MERs"]. Rows [0]. Delete ();
// Delete the first row of data in the customers table in Dataset
Sqldataadapter1.update (dsdataset1, "MERs ");
// Call the update method to update the data in dataset from the database
Dsdataset1.tables ["MERs"]. acceptchanges ();
// -- Thing
Sqlconnection myconnection = new sqlconnection ("Server = (local); initial catalog = northwind; uid = sa; Pwd = 111 ;");
Myconnection. open ();
// Start a transaction
Sqltransaction mytrans = myconnection. begintransaction ();
// Create a command for the transaction
Sqlcommand mycommand = new sqlcommand ();
Mycommand. Connection = myconnection;
Mycommand. Transaction = mytrans;
Try
{
Mycommand. commandtext = "insert into region (regionid, regiondescription) values (110, 'description ')";
Mycommand. executenonquery ();
// Mytrans. Commit ();
Mycommand. commandtext = "insert into region (regionid, regiondescription) values (111, 'description ')";
Mycommand. executenonquery ();
// Submit. It is used to execute all execution statements together. If there is an error, throw it.
Mytrans. Commit ();
Response. Write ("successful write record! ");
}
Catch (exception ex)
{
// Roll back data
Mytrans. rollback ();
Response. Write (ex. tostring ());
Response. Write ("failed to write to database! ");
}
Finally
{
Myconnection. Close ();
}
}
}
// Create constraints
Sqlconnection mysqlcon = new sqlconnection ("Server =.; uid = sa; Pwd = sa; database = northwind ");
Sqldataadapter mydataadapter1 = new sqldataadapter ("select * from MERs", mysqlcon );
Sqldataadapter mydataadapter2 = new sqldataadapter ("select * from orders", mysqlcon );
Mysqlcon. open ();
Dataset dataset1 = new dataset ();
Mydataadapter1.fill (dataset1, "MERs ");
Mydataadapter2.fill (dataset1, "orders"); mainly creates a table with constraints ------------------ main CCB ------------ columns -----------------------------
Datarelation RR = dataset1. relations. Add ("MERs", dataset1.tables ["customers"]. Columns ["customerid"],
/** // External creation Constraint
Dataset1.tables ["orders"]. Columns ["mermerid"]);
Foreach (datarow prow in dataset1.tables ["MERs"]. Rows)
{// Create a cycle for a layman
Response. Write (prow ["mermerid"]);
Foreach (datarow crow in prow. getchildrows (RR ))
Internal build cycle
Response. Write (crow ["ordid"]);
}