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

Save Recordset Result to files

Status
Not open for further replies.

StateofTX

Programmer
Sep 6, 2001
8
US
Hi,

I need a little help on ASP and Recordset.

I have a query in my ASP page to select few data items from the company table (SQL 2000 database), and I have some code to display the result from the Recordset. On the same page, I also have a pull down window of file types (Access, Excel, Text File, etc.) and a "Save" button. It lets the user to select a file type to save the result as. My question is how do I pass the Recordset to another ASP page or if there is a better way of doing it.

The ASP code looks like:

set cn = Server.CreateObject("ADODB.Connection")
cn.ConnectionString = ConnectionStr
cn.Open

set rs = Server.CreateObject("ADODB.Recordset")
rs.ActiveConnection = cn
SQLStr = "select Company, address, date from company"
rs.Open SQLStr
' some code to display the result


Thanks in advance.

 
"...My question is how do I pass the Recordset to another ASP page... "

Stick it in Session.

;-)
 
Personally I would not put it in the session, but I would just re-create the recordset with the same code on the next page.

G -GTM Solutions, Home of USITE-
-=
 


stateoftx,

I agree with Geee, why not just pass the SQL query string to the next page? Your recordset could be very large and you would have to figure all sorts of "request.form" variables? That's really not efficient.

Passing the SQL querystring would in fact be very simple.

fengshui1998
 
Thanks.

I thought about passing the SQL string to the ASP, but would that be slow since I call the same stored procedure twice?

 
No, as far as load on your server goes, you are putting far less strain by creating the recordset twice, than storing it in a session.

G -GTM Solutions, Home of USITE-
-=
 
Hello TX,

Yes it is twice the work, but SQL Server is very fast, users will not notice this. And if you call a stored procedure instead of passing the query string, it will be even faster.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top