Sqlcommandbuilder automatically constructs SQL commands for images
Source: Internet
Author: User
StringSconnectonstring;
Sconnectonstring="Password = sa; user id = sa; initial catalog = Master; Data Source = (local)";
Sqlconnection objconn=NewSqlconnection (sconnectonstring );
Objconn. open ();
Sqldataadapter daauthors=NewSqldataadapter ("Select * From city_users", Objconn );
Dataset dsmaster=NewDataset ("Master");
Daauthors. fillschema (dsmaster, schematype. source,"City_users");//Load the structure of the table so that you do not need to reset the primary key when loading the table to dataset. Daauthors. Fill (dsmaster,"City_users");
Dsmaster. Tables ["City_users"]. Rows [1] ["User_name"]="SQL";//Note that rows [1] Here, this 1 refers to the row number in the Table in dataset, which is inconsistent with the row number in the database 1
Sqlcommandbuilder objcommandbuilder=NewSqlcommandbuilder (daauthors );//Build SQL commands Daauthors. Update (dsmaster,"City_users");//Update //Daauthors. updatecommand = updatecomm; //Daauthors. updatecommand. executenonquery (); Objconn. Close ();
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service