erstwhileShirker
Programmer
Working on ASP page which returns the results of three ADODB queries to populate drop down menus. If I return from connection from a function, it does not seem to work. Is this because the type of the returned value in VBScript is Variant? If the connection is returned, then it can be closed once the three queries
I'd like to do this-:
============================================
conn = dbConnection()
rs = dbQuery(table, field)
while not rs.EOF
%> <option value="<%=rs("Field")%>"><%=rs("Field")
%>
</option>
<%
rs.MoveNext
wend
set rs = nothing
rs = dbQuery(table2, field2)
while not rs.EOF
%> <option value="<%=rs("Field")%>"><%=rs("Field")
%>
</option>
<%
rs.MoveNext
wend
set rs = nothing
etc
conn.Close
conn = nothing
=====================================
but the only working version I've managed is
=====================================
rs = sqlConnect(table, field) ' Opens connection in here
' Leaves connection open
<populate drop down 1>
sqlConnect(table, field) ' Opens connection in here
' Leaves connection open
<populate drop down 2>
Can't close connnection, unless i make it global.
What is the normal idiom, use a function and
return the connection (which I couldnt get to work, error
424 Object Required) or make the connection object global?
At present the code leaks memory as I see it.
thanks
I'd like to do this-:
============================================
conn = dbConnection()
rs = dbQuery(table, field)
while not rs.EOF
%> <option value="<%=rs("Field")%>"><%=rs("Field")
%>
</option>
<%
rs.MoveNext
wend
set rs = nothing
rs = dbQuery(table2, field2)
while not rs.EOF
%> <option value="<%=rs("Field")%>"><%=rs("Field")
%>
</option>
<%
rs.MoveNext
wend
set rs = nothing
etc
conn.Close
conn = nothing
=====================================
but the only working version I've managed is
=====================================
rs = sqlConnect(table, field) ' Opens connection in here
' Leaves connection open
<populate drop down 1>
sqlConnect(table, field) ' Opens connection in here
' Leaves connection open
<populate drop down 2>
Can't close connnection, unless i make it global.
What is the normal idiom, use a function and
return the connection (which I couldnt get to work, error
424 Object Required) or make the connection object global?
At present the code leaks memory as I see it.
thanks