I would like an object that is used on many pages to contain its own connection and recordset variables so that they do not need to be declared on each page that wants to directly access the recordset, rather than interact with the functions of the object that normally handle this.
However, the recordset is apparently not becoming an object.
<!--
METADATA
TYPE="TypeLib"
NAME="Microsoft ActiveX Data Objects 2.5 Library"
UUID="{00000205-0000-0010-8000-00AA006D2EA4}"
-->
And
<%
Option Explicit
Class cls
Public conn
Public rs
Public Sub OpenRS(ByRef conn, ByRef rs, ByRef sql, ByRef Mode,
ByRef CursorType, ByRef LockType)
Set conn = Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Mode = Mode
conn.Open = Server.MapPath(".") & "\mb\testdb.mdb"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorType = CursorType
rs.LockType = LockType
rs.ActiveConnection = conn
rs.Open sql
End Sub
Public Sub CloseRS(ByRef conn, ByRef rs)
If VarType(rs) = vbObject Then rs.Close
Set rs = Nothing
If VarType(conn) = vbObject Then conn.Close
Set conn = Nothing
End Sub
Private Sub Class_Initialize()
Set conn = Nothing
Set rs = Nothing
End Sub
End Class
Dim a: Set a = New cls
a.OpenRS a.conn,a.rs, "SELECT * FROM emp",
adModeRead, adOpenForwardOnly, adLockPessimistic
Response.Write(a.rs.EOF)
%>