Copy codeThe Code is as follows: '*************************************** *****
'The following are database-related functions
'*************************************** *****
'================================================ =====
'Initialize the database connection object
'Usage principle: call at the latest and release at the earliest
'================================================ =====
Sub DBConnBegin ()
'If the database object has been opened, do not open it again
If IsObject (oConn) = True Then Exit Sub
'You can directly open record set objects without opening database connection objects, but if you need to open multiple record set objects, the efficiency is very low.
'If you do not create a database connection object, ADO will automatically create a new database connection object when each record set is opened, even if you use the same SQL statement.
Set oConn = Server. CreateObject ("ADODB. Connection ")
On Error Resume Next
OConn. Open "Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" & Server. MapPath ("db/lbedit. mdb ")
If Err. Number> 0 Then
'The error message is displayed and an email is sent to the Administrator.
'Call DBConnError (Err)
'Completely exit the running script
Response. End
End If
'Create a record set
Set oRs = Server. CreateObject ("ADODB. Recordset ")
End Sub