Soldato
- Joined
- 18 Oct 2002
- Posts
- 15,980
- Location
- The land of milk & beans
Hi all.
I'm currently trying to make myself a few classes and include files to standardise the work I do, and hopefully make things a bit neater too, but I'm having a few problems.
Here's an example
usefulfuncs.asp...
default.asp, includes usefulfuncs.asp
rsAdmin does not do anything at all, it does not contain a recordset, nor does it cause an error (even when used like response.write(rsAdmin.foobar)
Anyone know whats going on here?
I'm currently trying to make myself a few classes and include files to standardise the work I do, and hopefully make things a bit neater too, but I'm having a few problems.
Here's an example
usefulfuncs.asp...
Code:
' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= \/ \/ \/ \/ =-
' LoadRSFromDB
' IN: Object: ADO Connection; String: SQL statement
' OUT: Disconnected recordset
' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
function LoadRSFromDB(p_cn, byval p_SQL)
dim p_rs
if len(p_SQL & "") <= 0 then err.raise 1, "UsefulFuncs: LoadRSFromDB", "No SQL statement provided [UF003]"
set p_rs = Server.CreateObject("ADODB.Recordset")
p_rs.Open p_SQL, p_cn, adOpenForwardOnly, adLockReadOnly
' Error handler
if err <> 0 then
err.raise err.number, "UsefulFuncs: LoadRSFromDB", err.Description & " [UF004]"
end if
' Disconnect the recordset
set p_rs.ActiveConnection = nothing
' Return
set LoadRSFromDB = p_rs
end function
' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= /\ /\ /\ /\ =-
default.asp, includes usefulfuncs.asp
Code:
set rsAdmin = LoadRSFromDB(cn, "SELECT * FROM Admin;")
Response.Write(rsAdmin.Recordcount)
rsAdmin does not do anything at all, it does not contain a recordset, nor does it cause an error (even when used like response.write(rsAdmin.foobar)
Anyone know whats going on here?
Last edited: