Sub DeleteObject(ByRef obj)
Set obj = nothing
obj = null
End Sub
Class CDB
private m_oConn, m_oRS
private m_pageIndex, m_pageSize, m_pageCount, m_recordCount
private strError
private m_QueryString
private Sub Class_Initialize()
m_oConn = null
m_oRS = null
m_pageIndex = 1
m_pageSize = 10
m_pageCount = 1
m_recordCount = 0
Call connect()
End Sub
private property Get GetConnectionString()
if InStr(LCase(Request.ServerVariables("SCRIPT_NAME")), "/admin/") > 0 then
GetConnectionString = "Provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("DataBasedata.mdb")
else
GetConnectionString = "Provider=microsoft.jet.oledb.4.0;data source=" & Server.MapPath("AdminDataBasedata.mdb")
end if
end property
public property Let SetPageSize(num)
if Not isNumeric(num) then Exit property
num = CInt(num)
if num > 0 Then m_pageSize = num
End property
'object.AppendSearch(paraName) = paraValue
public property Let AppendQueryString(paraName, paraValue)
m_QueryString = m_QueryString & "&" & paraName & "=" & Server.URLEncode(paraValue)
end property
public property Let SetPageIndex(num)
if Not isNumeric(num) then Exit property
num = CInt(num)
if num > 0 then m_pageIndex = num
End property
public default function toString()
toString = strError
end function
private sub Connect()
Set m_oConn = Server.CreateObject("ADODB.Connection")
m_oConn.ConnectionString = GetConnectionString
m_oConn.Open()
if err then
strError = err.Description
Response.write("Sorry, failed to connect Database!")
err.Clear()
DeleteObject(m_oConn)
Response.End()
end if
end sub
private sub Close(ByRef DBObject)
if 1 = DBObject.state then Call DBObject.Close()
end sub
public function ExecuteScalar(strSql)
ExecuteScalar = m_oConn.Execute(strSql)(0)
end function
public sub Execute(ByVal strSql)
if (Not isObject(m_oConn)) then Exit Sub
m_oConn.Execute(strSql)
end sub
private function OpenRS()
OpenRS = false
if ((Not isObject(m_oConn)) Or m_oConn.State = 0) then exit function
if (isObject(m_oRS)) then
&nb