To create a database connection, first create an instance of the Connection object, create a Connection object instance using the script below:
Set conn = server.creatobject ("adoDb.connection")
Dbpath = server.mappath (user .mdb ")
Conn.open "driver = {Microsoft Access Driver (*. MDB); DBQ =" & dbpath
At this time, the database has been established, and the "IsObject ()" function can be used to test whether the connection has been completed, the code is as follows:
IF IsObject (conn) THEN
Response.write "Link"
Else
Response.write "Unlink"
END IF
After completing the link of the database, you can use the EXECUTE method of the Connection object to perform the Structure Query Language (SQL) to query the source of the database and retrieve the results.
Statement select uses data records in the database to implement queries as needed, and its grammar form is:
SELECT query field name from Query Object WHERE Query Condition ORDER BY Sort Field name ASC | DESC
Statement INSERT implementation adds new records to the database, and its grammar form is as follows:
INSERT INTO Name (Field 1, Field 2, .....) VALUES ('value 1', 'value 2', .....)
Updating the records already existing in the database table is an UPDATE statement:
Update Table Name Set Field Name = 'Value' Where Update Condition
Remove the deletion of the DELETE statement, its grammar form is as follows:
DELETE FROM Name WHERE Delete Conditions
Close method terminates the connection of the Connection object and the database
Finally, the resource is also released, and the following code is implemented:
Set conn = noting