ASP.net learning Purpose: Learn to add delete modify record
We used to add or delete records in the ASP, or use SQL statements with execute () or simply use the recordset's new, delete, and update methods. In asp.net we use the SQL statement plus the command object to execute the SQL statement to add a delete modification record. This is more simple than the last time you read the record. In fact there is only one difference, the ExecuteReader () is modified to ExecuteNonQuery (), because we do not need to return the value AH.
String strconnection= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=";
Strconnection+=server.mappath (STRDB);
OleDbConnection objconnection=new OleDbConnection (strconnection);
OleDbCommand objcommand = new OleDbCommand ("Here is SQL statement", objconnection);
Objconnection.open ();
OleDbDataReader objdatareader=objcommand.executenonquery ();
--------------------------------------------------------------------------------
Dim objconnection As OleDbConnection
Dim objcommand As OleDbCommand
Objconnection=new OleDbConnection (Provider=Microsoft.Jet.OLEDB.4.0;Data source= "+Server.MapPath (strDb))
Objcommand=new OleDbCommand ("Here is the SQL statement", objconnection)
Objconnection.open ()
Objdatareader=objcommand.executenoquery ()
The following example illustrates the SQL statement (ACCESS):
Add record: Insert int
o Table name (field 1, Field 2) values (string 1, String 2) Where condition
Delete Record: Delete from table name where condition
Modify record: Update table name set field 1=xx, field 2=xxwhere condition
It is necessary to note that if the SQL Server delete record is a delete table name, it does not need to be added from.
That's it for today, tomorrow is the most famous datagrid in asp.net.
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