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 2. ASP and SQL database connection:
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 creates 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. Establishment and deletion of data sheets:
Create Table Data Sheet Name (Field 1 Type 1 (Length), Field 2 Type 2 (Length) ...) Example: Create Table Tab01 (Name Varchar (50), DateTime Default Now () DROP TABLE DATA Name (permanent Delete a data sheet) Method for recording a set object: rs.Movenext Moves the record pointer down the current position down Rs.MovePrevious to move the record pointer from the current location RS.MOVEFirst to move the record pointer to the data table first Row rs.movelast moves the record pointer to the last line RS.AbsolutePosition = N Move 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 Setting each page for n-record RS.PageCount Returns the total number RS.Recordcount Returns the total number RS.BOF Returns the record pointer to whether the value is over the data sheet header, the true said rs.eof returns a record pointer Whether it exceeds the end of the data table, true, whether false is 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 end RS.UPDATE Update Data Table Record Judgment Fill data is a number 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