Common code for WEB programming and development

Source: Internet
Author: User
Tags access database
 
1. ASP and Access database connection:
Dim conn, mdbfile
Mdbfile = server. mappath ("database name. mdb ")
Set conn = server. createobject ("adodb. connection ")
'Conn. open "driver = {microsoft access driver (*. mdb)}; uid = admin; pwd = database password; dbq =" & mdbfile
Conn. open "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & mdbfile
2. Connection between ASP and SQL database: dim conn
Set conn = server. createobject ("ADODB. connection ")
Con. open "PROVIDER = SQLOLEDB; data source = SQL server name or IP address; UID = sa; PWD = DATABASE password; DATABASE = DATABASE name ;"
 
Set rs = server. createobject ("adodb. recordset ")
Rs. open SQL statement, conn, 3, 2
Common SQL commands:
Data Record filtering: SQL = "select * from data table where field name = field value order by field name"
SQL = "select * from data table where field name like '% field value %' order by field name"
SQL = "select top 10 * from data table where field name order by field name"
SQL = "select * from data table where field name in ('value 1', 'value 2', 'value 3 ')"
SQL = "select * from data table where field name between value 1 and value 2" update data record: SQL = "update data table set field name = field value where condition expression"
SQL = "update data table set Field 1 = value 1, field 2 = value 2 ...... Field n = value n where condition expression"
Delete data records: SQL = "delete from data table where condition expression"
SQL = "delete from Data Table" (delete all data table Records)
Add data records: SQL = "insert into data table (Field 1, field 2, Field 3 ...) Valuess (value 1, value 2, value 3 ...) "
SQL = "insert into target data table select * from Source Data Table" (add records of source data table to target data table) data record statistical function:

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.