Asp database connection functions

Source: Internet
Author: User

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

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.