Transfer from: http://blog.9cbs.net/goaler/archive/2005/01/13/251090.aspx1. 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
2. ASP and SQL database connection:
DIM Conn Set Conn = Server.createObject ("AdoDb.Connection") Con -.open "provider = SQLOLDB; DATA SOURCE = SQL server name or IP address; UID = SA; PWD = database password; Database = database name
Establish record set objects:
SET RS = Server.createObject ("AdoDb.Recordset") RS.Open SQL statement, CONN, 3, 2
SQL common command usage:
Data Record Filter:
SQL = "SELECT * FROM DATA WHERE Field Name = Field Value ORDER BY Field Name" SQL = "SELECT * FROM DATA WHERE Field Name Like '% Field Value%' Order BY Field Name" SQL = "SELECT TOP 10 * from Data Sheet WHERE Field Name ORDER BY Field Name "SQL =" SELECT * FROM Datasheet WHERE Field Name in ('value 1', 'value 2', 'value 3') "SQL =" SELECT * FROM Datasheet 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 Conditions Expression
Delete data records:
SQL = "delete from data table where condition expression" SQL = "delete from data table" (delete data tables)
Add a data record:
SQL = "INSERT INTO Data Sheet (Field 1, Field 2, Field 3 ...) Valuess (value 1, value 2, value 3 ...)" SQL = "INSERT INTO target data table select * from" source data " Table record added to the target data sheet)
Data Recording Statistics: AVG (Field Name) Delivering a table bar average count (* | field name) Statistics on the number of data lines or the number of data line counts for a value value for a certain column (field name) get a form The largest value of the column Min (field name) gets the smallest value of a table column SUM (field name) adds the value of the data bar.
Citing the above function:
SQL = "SELECT SUM (field name) AS alias from Datasheet Where WHERE Condition Expression" SET RS = Conn.excute (SQL) The value of the value is obtained by RS ("alias", and other functions are using the same.
The establishment and deletion of the data sheet: CREATE TABLE DATA Name (Field 1 Type 1 (Length), Field 2 Type 2 (Length) ...) Example: Create Table Tab01 (Name Varchar (50), DateTime Default Now () DROP TABLE Dataset Name (permanently delete a data sheet)
Record the method of the set object:
Rs.MoveNext moves the record pointer down the current position down RS.MOVEPREVIOS to move the logger from the current location to the top RS.MoveFirst Move the record pointer to the data table RS.MOVELAST Move the record pointer to the data table The last row RS.absolutePosition = n Moves the record pointer to the data table nth line rs.absolutepage = n Move the record pointer to the first line of the first line of the nth page RS.Pagesize = n Sets each page for n-record RS.PageCount PageSize's Settings Returns the total number rs.RecordCount Returns the total number RS.BOF Returns the record pointer beyond the data table header, the true said whether false is rs.eof returns a record pointer over the end of the data table, true, true Has Rs.Delete deletes the current record, but the record pointer does not move the rs.addnew to add the record to the data table end RS.UPDATE Update Data Table Record
Judging the filled data is a digital type
If not isnumeric (Request ("Field Name")) Then Response.write "Not Digital" Else Response.write "Digital" end if
Page execution time:
<% startime = Timer ()%> .... .... Content ... End <% DIM endtime endtime = Timer () response.write page execution time: & formatNumber (EndTime-Startime) * 1000, 5) & " font> millisecond"%>
Define the size of the start window while opening the web page