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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maintain and query a recordset after closing a connection

Status
Not open for further replies.

jeffcullina

Programmer
May 13, 2002
80
US
At the start of my ASP, I open a connection and then open a recordset from a database. Can I close the connection and keep the recordset open so I can draw from it in later client-side vbscript? I would like to run queries on the recordset when the user presses a button on the page. Alternatively, can I copy the information from the recordset into some other recordset or array variable that I can use in my client side code. The two server-side code at the top of the page would look something like this:

<%
'Open connection
'Open recordset
sampleRS.Open &quot;SELECT Num FROM tblSample;&quot; , conn
'Close connection
%>

I need help replacing the comments in the client side code below:

<script language=&quot;vbscript&quot;>
function UpdateNum()
'Run some query on sampleRS.
'For example: &quot;SELECT Num FROM sampleRS WHERE Num<10&quot;
end function
</script>

 
You can use a disconnected recordset to achieve this. You can create a component to do this.

Another way is to loop thru the recordset when it is open and put the values into arrays.
 
One note, since your are creating this recordset object server-side you will be able to disconnect it and still access the data retrieved the last time the set was opened from the server but not from the client. Since you are only passing a flat text file to the client you can't pass complicated objects like recordsets from the server-side code, You will need to either write this data into an array from your server-side ASP to client-side VBScript or have the page submit back to the server to be updated with a newer query.

-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
No more vacation for me :(

FAQ FAQ20-2863
= new Forums.Posting.General.GettingAnswers()
 
Thanks. I read the 4Guys From Motorolla article, and it does not quite address referencing the disconnecting recordset from the client side. From what I understand, I cannot copy a server side recordset into a client side recordset, though I can copy an array or any other variable. manjulam suggests I should be able to use the recordset by creating a component. If that is true, I guess I will need to be walked through it. For now I am setting up arrays. I still have one problem - I can't get the index to change. My client side code is posted below. The variable servcount is what I am having problems with.

function UpdateID2()
dim SID(1000), icount, numrec
numrec = &quot;<%=servcount%>&quot;
<% servcount = 0 %>
For icount = 0 to numrec
SID(icount) = &quot;<%=servSID(servcount)%>&quot;
<% servcount = servcount + 1 %>
Next
end function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top