ASP database Connection function _ Application technique

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.