A problem was encountered when writing a program recently, the insert content in the text type (SQL SERVER) field cannot be used directly with SQL statements, because there are newline, special characters. So you can only use a dataset. Remember in the ASP in the writing is Rs.addnew (), rs.update (), etc., in the asp.net is how to write it? After half a day of information (incredibly hard to find), write down some of these basic operations.
The following program is written from the dataset already established.
Delete a record that already exists DataRow Dr;
int Vsno=int32.parse (txtsno.text);
dr=dataset11.tables["Student"]. Rows.find (Vsno)
Dr. Delete ();
Sqldataadapter1.update (dataSet11, "Student");
insert a new record
int Vsno=int32.parse (txtsno.text);
int Vscore=int32.parse (txtscore.text);
DataRow Dradd
dradd=dataset11.tables["Student"]. NewRow ();
Dradd[0]=vsno;
Dradd[1]=txtfname.text;
Dradd[2]=txtlname.text;
Dradd[3]=vscore;
dataset11.tables["Student"]. Rows.Add (Dradd);
SqlCommandBuilder Mybuilder = new SqlCommandBuilder (sqlDataAdapter1);
Sqldataadapter1.update (dataSet11, "Student");
edit a record that already exists
int Vsno=int32.parse (txtsno.text);
int Vscore=int32.parse (txtscore.text);
Drupdate.beginedit ();
drupdate["SNo"]=VSNO;
drupdate["FirstName"]=txtfname.text;
drupdate["LastName"]=txtlname.text;
drupdate["Score"]=vscore;
Drupdate.endedit ();
Sqldataadapter1.update (dataSet11, "Student");
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