<%
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'Database operation class
'%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
'Name: Class_DBPerate
'Version: 0.2
'Author: qihangnet
'Update: June 14, 2005
'Function: Simplify the process of database operations
'Authorization: Free to 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()
SetConn=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)
' Parameter: str --- string
Property Let ConnectString(str)
Conn_Str = str
End Property
'************************************
'event
'************************************
'Database opens
Public Sub DB_Open() .
Conn.ConnectionString = Conn_Str
Conn.Open
End Sub
'Database is closed
Public Sub DB_Close()
Conn.Close
End Sub
'************************************
'method
'************************************
'Database query (sql statement)
'Parameters and categories: sql ---- string
'Return value type: recordset
' Prerequisite: The 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: integer
'Return value meaning: number of affected rows
' Prerequisite: The 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
%>