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 = "& mdbfileconn.open" provider = microsoft.jet.Oledb.4.0; data source = "& 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 object:
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 Condition Expression" Delete Data Record :
SQL = "Delete from Data Sheet WHERE Condition Expression" SQL = "Delete from Datasheet" Add 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 Add to Target Data Table) Data Recording Statistics: AVG (Field Name) Deliver a table column average count (* | field name) Statistics on the number of data lines or values for a certain column Statistics Max (Field Name) gets the maximum value of a table bar minimizes the smallest value SUM (field name) with the smallest value of a table column to add the value of the data bar to 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 Data Sheet Name (Permanent Delete A Data Table) Record the object method:
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 the RS.Delete deletes the current record, but the record pointer does not move the rs.addnew to add the RS.AddNew to the data table Rs.Update Update Data Table Record Judgment The filled data is a digital type
If not isnumeric (Request ("Field Name")) The response.write "is not a digital" ELSE RESPONSE.WRITE "number" 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 when opening the web page