ASP add data implementation code

Source: Internet
Author: User

Example:

For example, enter username, password, email, and telphone in the field name.
Note: different field names are separated by commas (,) and asterisks are not supported.
Enter the name of the table to be queried, for example, Table1.
Front-end form page:
Pay attention to the name attribute of the input field.
Commonly used add data under ASPCodeYes:
Use ADODB. recordset
The advantage is that the database is relatively simple to store in the database, so you do not need to consider single quotation marks. It is not prone to errors.Copy codeThe Code is as follows: username = request ("username ")
Password = request ("password ")
Email = request ("email ")
Telphone = request ("telphone ")
SQL = "select * From Table1"
Rs. Open SQL, Conn, 1, 3
Rs. addnew
RS ("username") = Username
RS ("password") = Password
RS ("email") = Email
RS ("telphone") = telphone
Rs. Update
Rs. Close

The second method is to use SQL data to achieve high storage efficiency, but it is prone to problems. single quotation marks and other issues need to be considered.
The above code is actually an encapsulation of SQL insert statements.Copy codeThe Code is as follows: Set conn = server. Createobject ("ADODB. Connection ")
'Create recordset object Method
Set rst = server. Createobject ("ADODB. recordset ")
Set rst1=conn.exe cute ("insert into user (u_user, u_pass) values ('" & request. form ("u_user") & "','" & request. form ("u_pass ")&"')")

Friendly reminder: In order to ensure security, in many cases, the user's input content needs to be converted in a sense. For example
Username‑server.html encode (Request ("username "))
In this way, some scripts are not run, for example, <SCRIPT> will become <SCRIPT>

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.