A Simple ASP database operation class

Source: Internet
Author: User
Data | database

<%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Database Operations class
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
' Name: class_dboperate
' Version: 0.2
' Author: qihangnet
' Updated: June 14, 2005
' Role: Streamline the process of database operations
' Authorization: Free use
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Class class_dboperate

'************************************
' Variable definition
'************************************
' Conn----------Database Connection object
' CONN_STR------Database connection string

Private Conn,conn_str

'************************************
' Instance initialization/termination
'************************************

Private Sub Class_Initialize ()
Set Conn = Server.CreateObject ("ADODB. Connection ")
End Sub

Private Sub class_teriminate ()
Set Conn = Nothing
End Sub

'************************************
' Property
'************************************

' Output database connection string
' Return value type: string

Property Get ConnectString
ConnectString = Conn_str
End Property

' Set database connection string (database connection string)
' Argument: str---string

Property Let ConnectString (str)
Conn_str = Str
End Property

'************************************
' Events
'************************************

' Database open
Public Sub Db_open ().
conn.connectionstring = Conn_str
Conn.Open
End Sub

' Database shutdown
Public Sub Db_close ()
Conn.close
End Sub

'************************************
' Method
'************************************

' Database query (SQL statement)
' Parameters and Categories: SQL----string
' Return value type: Recordset
' Prerequisite: Database status is open

Public Function db_select (SQL)
Set db_select = conn.execute (SQL)
End Function

' Database Execution (SQL statement)
' Parameters and Categories: SQL----string
' Return value type: shaping
' Return value meaning: number of affected rows
' Prerequisite: Database status is open

Public Function db_excute (SQL)
Dim rs_affected
Conn.execute sql,rs_affected
Db_excute = rs_affected
End Function

End Class
%>







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.