Database operations classes on the Internet a lot, I this is not better than those, just write their own, with more habits. So I have nothing special in this category, just use their habits, as for efficiency, etc., Welcome to enlighten!!
<%
Class Dbclass
'-------------------------------------------------------------------------
' Variable description
' Conn-----------Connection object
' strSQL---------The statement that executes the query
' Vtbname table name--------Query paging
' Vpkey----------The primary key of a table that queries pagination
' vpgfields------Query paging fields to display
' Vpgsize--------The number of records displayed per page of the query page
' Vcurrpg the current page displayed--------query paging
' vconditions----Query paging conditions
' Vorderby-------Query paging sorting
'-------------------------------------------------------------------------
Private Conn,strsql,vtbname,vpkey,vpgfields,vpgsize,vcurrpg,vconditions,vorderby
' Initialization of the class
Private Sub Class_Initialize ()
' Set the following two variables when it is an MS SQL database
The name or IP address of the ' Dim dbserver ' Database Server
Name of the ' Dim dbname ' Database
Dim DBPath ' If an Access database, set its path here
Dim Dbuser ' Login Username for database
Dim dbpass ' Login Password for database
Dim connstr
DBPath = "/testasp/data/data.mdb" Set database path
Dbuser = "Admin"
Dbpass = "123456"
' If you have access, and you have a password
ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & Server.MapPath (DBPath) &_
"; User id= "& Dbuser &"; password=; Jet oledb:database password= "& Dbpass
' If access, and no password
' ConnStr = ' Provider = microsoft.jet.oledb.4.0;data Source = ' & Server.MapPath (DBPath)
' If the Ms-sql database
' ConnStr = ' Provider = SQLOLEDB; User ID = "& Dbuser &"; Password = "& Dbpass &_
' "; Initial Catalog = "& dbname &"; Data Source = "& DBServer
On Error Resume Next
Set Conn=server. CreateObject ("Adodb.connection")
Conn.Open ConnStr
ErrMsg "Connection Database"
End Sub
' Class end
Private Sub Class_Terminate ()
Conn.close
Set conn=nothing
End Sub
'-------------------------------------------------------------------------
' Set the value of the variable for the class
'-------------------------------------------------------------------------
' Set up SQL statements
Public Property Let Sqlstr (Byval Values)
Strsql=values
End Property
' Set table name for query paging
Public Property Let Tbname (Byval Values)
Vtbname=values
End Property
'--------------------------------------------------------
' Set the primary key for a table that queries pagination
Public Property Let Pkey (ByVal Values)
Vpkey=values
End Property
'--------------------------------------------------------
' Set the fields displayed
Public Property Let Pgfields (ByVal Values)
Vpgfields=values
End Property
'--------------------------------------------------------
' Set the number of records to display per page
Public Property Let Pgsize (ByVal Values)
Vpgsize=values
End Property
'---------------------------------------------------------