Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass a recordset to a button_onclick event 1

Status
Not open for further replies.

Gamera99

Programmer
May 17, 2001
59
JP
I am writing ASPs in Interdev 6. I make my own recordsets, like:

dim rsRole
set rsRole = Server.CreateObject("ADODB.Recordset")
sql = "select * from Role"
rsRole.Open sql, conn

and I am using some button DTCs. I don't want to use Recordset DTCs for some of my recordsets.

My problem is: How can I make the handwritten recordset visible to the subroutine I am writing for a btn_onClick() event? A recordset DTC is visible within the recordset but my handwritten recordset is not. Can anyone tell me how to state the recordset variable so that it has scope across the entire page, in all subroutines?
Thanks if anyone can help.
 
If you want to give your recordset object page scope, then don't declare it in a subroutine:

ex:)

<%
dim rs
set rs = server.createobject(&quot;ADODB.Recordset&quot;)
%>

would have page scope as opposed to:

<%
sub makeRS()
dim rs
set rs = server.createobject(&quot;ADODB.Recordset&quot;)
end sub
%>

would only have scope within the subroutine, makeRS

hope that helps! :)
Paul Prewett
penny.gif
penny.gif
 
Paul I agree with you that makes sense, but I still get an Object Not Found error.

If I say on the page somewhere:
<%
Dim rsRole
set rsRole = Server.CreateObject(&quot;ADODB.Recordset&quot;)
%>
and later I say

<%
sub lbRole_Populate()
dim conn
Set conn = Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Open strDSN
sql = &quot;select * from Role&quot;
rsRole.Open sql, conn
etc, etc, etc.....
end sub
%>

It won't see the recordset object that was earlier instantiated. And if I put dim statement outside, and put set recordset statement inside the subroutine, then other subroutines can't see the recordset either?

I can't pass the recordset variable name to the subroutine because I originally call for the subroutine in a button_onClick() event, which doesn't provide any method of passing a variable to it's associated onClick() event (that I know of).

Do you have any suggestions? Thanks Paul.
 
:-(

I don't use the DTC's in InterDev for these types of reasons, because to me, it seems perfectly logical that if you declare something to have page scope, then it should have page scope... period.

I have heard others complain about them because the code it creates is too hard to manually deal with.

I really wish I could be of more help, but I'm afraid I can't. :-(
penny.gif
penny.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top