How ADO uses update syntax

Source: Internet
Author: User
Tags one table
Update
An update expression that updates the data values of the fields in the table, where you can set a specific conditional expression, and records that match the conditional expressions are updated.
The syntax is as follows:
UPDATE table
New value for SET field
WHERE condition Expression
You need an update expression when you want to update multiple records at the same time, or when you update records in more than one table.
You can update the data values of multiple fields at the same time, for example, the following example will be all records in the product table, price 90 percent, freight 70 percent:
UPDATE Product
SET Price = Price * 0.9, freight = freight * 0.7
An update expression does not produce a recordset. When you update a record with an update expression, the original value cannot be restored. Therefore, if you want to know which records will be updated, it is recommended that you use Select and the same where condition expressions to query the results, to determine which records you want to update, and then to update the record by performing an update expression.
Of course you can copy the data at any time, in case you update the wrong records with an update expression, you can still save the records from your backup.
Let's look at an example of using this SQL instruction in ASP code.
For example, ASP code rs5.asp as follows, [Update product Set quantity = quantity + 10] Use Update to add 10 to the Quantity field data for all records in the product table:
<%
Set conn1 = Server.CreateObject ("ADODB. Connection ")
Conn1. Open "dbq=" & Server.MapPath ("Ntopsamp.mdb") & ";D river={microsoft Access Driver (*.mdb)};D riverid=25;fil=ms Access; "
sql = "Update product Set quantity = quantity + 10"
Set a = conn1. Execute (SQL)
Set RS3 = Server.CreateObject ("ADODB. Recordset ")
sql = "SELECT * from Product order by code"
Rs3. Open sql,conn1,1,1,1
%>
<table colspan=8 cellpadding=5 border=0>
<TR>
&LT;TD align=center bgcolor= "#800000" ><font color= "#FFFFFF" > Code </FONT></TD>
&LT;TD align=center bgcolor= "#800000" ><font color= "#FFFFFF" > Name </FONT></TD>
&LT;TD align=center bgcolor= "#800000" ><font color= "#FFFFFF" > Price </FONT></TD>
&LT;TD align=center bgcolor= "#800000" ><font color= "#FFFFFF" > Quantity </FONT></TD>

Contact Us

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

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.