1, database connection.
ASP to connect to an Access database:
ASP to connect to SQL database:
The DW uses string concatenation code:
"Driver={microsoft Access Driver (*.mdb)};D bq= Absolute path to the database"
When you are done, open the database server and
"Driver={microsoft Access Driver (*.mdb)};D bq= Absolute path to the database"
Into
"Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath ("Database path under Server root directory")
and modify the local server into a test server
2, loading other pages.
3, display the data in the database.
4, output.
Response.Write ("literal or string");
5. Open the database and set up the DataSet object.
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server. MapPath ("***/photodata.mdb") Change your database file storage path
Set Rs=server.createobject ("Adodb.recordset") to set up a dataset
Sql= "Select * from data" To change your database table name
Rs. Open sql,conn,1,1
6, to obtain the system time.
7, to obtain access to the IP.
8, random number.
N is a number that can be changed
9, jump page.
Response.Redirect ("page")
10, pop-up message box.
Response.Write ("")
11, use the hidden type to pass the variable.
<% form method= "POST" action= "mynextpage.asp" >
<% for per item in request.form% >
< input namee= "<%=item% >" type= "HIDDEN"
Value= "<%=server. HTMLEncode (Request.Form (item)% > ">
<% next% >
</form >
12, common SQL statement collation.
(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 * 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 Condition expression"
Sql= Update data Table set field 1= value 1, field 2= value 2 ... field n= value n Where Condition expression "
(3) Delete data records:
Sql= "Delete from data table where condition expression"
Sql= "Delete from data table" (delete all records from datasheet)
(4) Adding data records:
sql= INSERT into Data table (field 1, Field 2, Field 3 ...) VALUES (value 1, value 2, value 3 ...)
Sql= INSERT INTO Target datasheet SELECT * from source datasheet (add a record from the source datasheet to the destination datasheet)
(5) Data record statistic function:
AVG (field name) to derive a table column average
Count (*| field name) statistics on the number of data rows or the number of data rows that have a value for a column
Max (field name) gets the maximum value of a table column
Min (field name) gets the smallest value of a table column
sum (field name) adds the value of the data bar
How to reference the above function:
Sql= "Select sum (field name) as Alias from data table where condition expression"
Set Rs=conn.excute (SQL)
Using RS ("Alias") to obtain the value of the unified, other functions using the same.
(5) The establishment and deletion of the data table:
Create Table datasheet Name (field 1 type 1 (length), Field 2 type 2 (length) ...)
Example: Create TABLE tab01 (name varchar, datetime default Now ())
drop table datasheet name (permanently deletes a data table)