Copy Code code as follows:
' ********************************************
' The following is a database-related function
' ********************************************
' ============================================
' Initializing a database connection object
' Usage principle: Late call, earliest release
' ============================================
Sub Dbconnbegin ()
' If the database object is open, do not open it again
If IsObject (oconn) = True Then Exit Sub
' You can open a Recordset object without having to open the database connection object, but it's very inefficient if you need to open multiple Recordset objects.
' If you don't create a database connection object, ADO automatically creates a new database connection object when each recordset is opened, even if you are using 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
' Displays an error message and notifies the administrator by sending a message
' Call Dbconnerror (ERR)
' Completely quit the running script
Response.End
End If
' Create a recordset
Set oRs = Server.CreateObject ("ADODB. Recordset ")
End Sub