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 = SQLOLEDB; 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 Add to Target Data Sheet) Data Record Statistics:
AVG (field name) draws a table column average
Count (* | field name) Statistics on the number of data lines or the number of data line counts on a certain column
Max (field name) get the largest value of a table bar
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. 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)
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")) 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