Recommended: ASP tips: use the function InstrRev() to get the current file name The InstrRev function starts from the last search of the string, and is the preceding string. Give an example to illustrate its application: The following is the quoted content: <%Dim strTXT, posstrTXT=www.CuoXIn.com&q
1. Connect ASP to Access database:
| The following is the quoted content: <% 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 %> |
2. Connect ASP to SQL database:
The following is the quoted content: <% 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 %> Create a record set object: set rs=server.createobject(adodb.recordset) rs.open SQL statement,conn,3,2 |
3. Common SQL command usage methods:
(1) Data record filtering:
sql=select * from data table where field name=field value order by field name[desc]
sql=select * from data table where field name like '%field value %' order by field name [desc]
sql=select top 10 * from data table where field name order by field name [desc]
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
(2) Update data records:
sql=update data table set field name=field value where conditional expression
sql=update data table set Field 1=value 1, Field 2=value 2... Field n=value n where conditional expression
(3) Delete data records:
sql=delete from data table where conditional expression
sql=delete from data table (delete all records in the data table)
(4) Add data records:
sql=insert into data table (field 1, field 2, field 3…) values (value 1, value 2, value 3…)
sql=insert into target data table select * from source data table (add the record of the source data table to the target data table)
(5) Data record statistics function:
AVG (field name) to obtain an average value of a table column
COUNT(*¦ field name) Statistics on the number of data rows or statistics on the number of data rows with a value in a certain column
MAX (field name) Get the maximum value of a table column
MIN (field name) Get the minimum value of a table column
SUM (field name) adds the value of the data column
Reference the above function method:
sql=select sum(field name) as alias from data table where conditional expression
set rs=conn.excute(sql)
Use rs (alias) to get the statistics, and other functions are used the same as above.
(5) Establishment and deletion of data tables:
CREATE TABLE Data table name (field 1 type 1 (length), field 2 type 2 (length)…)
Share: ASP+Access safety hazards and solutions With the development of the Internet, web technology is changing with each passing day. Following the General Gateway Interface (CGI), ASP (Active Server Pages) is a typical server-side web design technology and is widely used in online banking, e-commerce, and search engines.