Solved

passing recordset to another page ?

Posted on 2001-06-06
14
253 Views
Last Modified: 2012-06-21
hi,

i got a recordset need to pass to my form (which is
in another page, e.g. order_list.asp), is it possible
to achieve that?

orders.asp    --- (recordset) -->   order_list.asp


in the orders.asp, i execute my sql statement. and
i need a way to pass my recordset (if can no session)

cheers,
klia
0
Comment
Question by:klia
  • 6
  • 4
  • 2
  • +2
14 Comments
 
LVL 2

Expert Comment

by:kmv
ID: 6158746
How can you pass parameters from one script page to other.
Best way is to use server-side methods.
1. Using Session or Application objects.
2. Write your own parameter storage object and use it on both pages. Use apartment model to avoid multiply access problem.
3. Using file (write to file on one page and then read from other). But you need to solve concurrent access problem (possible use Application.Lock and Application.Unlock)

Client-side passing.
Create page with form and place recordset fields in it (possible in a hidden fields). Then user submit form to other script. It will increase traffic but on some systems it is one way to pass parameters, e.g. some payment systems.

Good luck!
0
 

Author Comment

by:klia
ID: 6158785
in the order.asp, i do all the asp programming,
i try to mimimize the asp coding in my order_list.asp
where in the order.asp, i have case, db select and
other programming logic, while in order_list.asp, i
want to act as 'interface' only file with mimimal
asp logic inside.
0
 
LVL 7

Expert Comment

by:weesiong
ID: 6158940
klia,

Best way using input type

sample:
<input type="hidden" name="ID" value="<%=Rs("ID")%>">

Regards,
Wee Siong
0
 
LVL 4

Expert Comment

by:epeele
ID: 6159330
It sounds as though you simply want to use your ASP page, order.asp, like an object.  If your web application is on a Windows 2000 Server, you can use:

Server.Execute("order.asp")

This will go out and execute order.asp and return the results to the page that called it.  You can then use the recordset as though it were created within the order_list.asp page.  Additionally, any parameters, form values or query strings that are passed to order_list.asp are also accessible by order.asp.
0
 

Author Comment

by:klia
ID: 6160120
ok,

i try to write what i intend to, i still new in asp
coding, my previous language is php. i'm not sure
whether this method can be done using asp, but in
php, this is what i'm using, after select the record
i just include the order_list.asp and inside the
order_list.asp, i just display them. very easy.


order.asp
----------
<%
mode = request.querystring("mode") 'get the mode

select case Cstr(mode)

case "add"
    'prepre add a new record

case "edit"
    'get the data and pass to order_form.asp to edit
    strSql = "select * from orders where ordid = " & ordid
    rs.execute(strSql)
    ....
    ....

case else
    strSql = "select * from orders order by ordid"
    rs.execute(strSql)
    'i'm thinking how should i pass my rs to order_list.asp

end select
%>

order_list.asp
--------------

<html>
<body>
<%
'i know this is not asp code....

while rs.eof
   displayrecord
endwhile
%>
</body>
</html>
0
 
LVL 4

Expert Comment

by:epeele
ID: 6160151
Using your example, Server.Execute would not work. Instead you would have to use Server.Transfer.  This would make all elements including the recordset and form and querystring collections available to order_list.asp. Example:

case else
   strSql = "select * from orders order by ordid"
   rs.execute(strSql)
   Server.Transfer("order_list.asp")
end select


PS  -  Again, this will only work on Win2000

0
 

Expert Comment

by:alortiz
ID: 6161579
if I get it right, you want the 1st ASP (orders) page to retrieve a recordset, building the where clause using a parameter value.

if orderlist.asp, only needs to display the recordset results, and orders can produce an standard format you could take 2 approaches,

On the client side either use frames and DHTML, or an iframe, depending on your browser target, where one frame is used to make the browser load the window.

on IE 4 and above, you can do the following:

orderlist.asp:
<HTML>
<BODY>
<FORM action='orders.asp' target='orderlistframe'>

    <input ....>
</FORM>
<IFRAME name='orderlistframe' width="100%" height="100%"></IFRAME>
</BODY>
</HTML>

the netscape example is more complex, beacuse it envolves the following concepts:
<LAYER> tag
javascript client side programing for DHML.

On the server side, you can do the following:
convert your 1st page to a function as follows:

<script runat=server>
function orderlist(parameter)
   VBScript code
end function
</script>

and on the 2nd page, include the first one

<script runat=server src="theotherpage.asp">
</script>

after that, call the function from the asp page
<% call orderlist(parameter)%>

or you can use session variables, you may load an array to a session object, avoiding to create to many of them.

0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 2

Expert Comment

by:kmv
ID: 6162208
About Server.Execute
http://support.microsoft.com/support/kb/articles/Q224/3/63.ASP
http://msdn.microsoft.com/library/psdk/iisref/vbob9pid.htm
About Server.Transfer
http://msdn.microsoft.com/library/psdk/iisref/vbob9waa.htm

There is other technique:
Use SSI (server side include)
Let file orders.asp have input parameters in a query string or in a post header. I.e user calls order.asp,
order_list.asp will only show results of query.
In file order.asp you prepare recordset and store it in variable with certain name, e.g. rs. You don't write text to output buffer in file order.asp (except errors etc.)

in file order_list.asp you write smth like this
<html>
<body>
<%
while rs.eof
  'here you write code which will show your recordset fields. E.g.
  Response.Write "<tr><td>Item</td><td>"&rs("ItemName")&"</td>"
  Response.Write "<td>QTY</td><td>"&rs("ItemQTY")&"</td></tr>"
'or smth like this
endwhile
%>
</body>
</html>

In file orders.asp you place next code:
<%
'code to prepare recordset
'if it prepared correctly then
%>
<!--#include virtual="order_list.asp.asp"-->

That's all!
Text of order_list.asp will be included instead of line <!--#include virtual="order_list.asp.asp"--> (if you know C/C++ it is easy to understand for you)

About "include" directive
http://msdn.microsoft.com/library/psdk/iisref/iiwainc.htm

Good Luck!
0
 

Author Comment

by:klia
ID: 6162357
due to design, we cannot use any frame, (NS also didn't
support iframe if i'm not wrong)

for the order.asp, it will serve as 'controller' and
will accept the mode passing by the caller, either from
order_list.asp or order_form.asp etc. and then it will
evaluate the mode and act accordingly. I try to implement
this method using asp, while previously..I've been using
this method in my php programming. and we are very happy
cos it is fast and it seperate the interface part and
the coding part.

0
 
LVL 2

Expert Comment

by:kmv
ID: 6162555
Try #include directive
But better way to separate interface and coding part is XML/XSL
Use pasp - it helps to do it. But of course, it is possible to use simple asp.

Good luck!
0
 
LVL 2

Expert Comment

by:kmv
ID: 6162565
#include doesn't mean frames. Read article please.
http://msdn.microsoft.com/library/psdk/iisref/iiwainc.htm

It is simplest way. But you need to carefully use names of your variables, recordsets etc.
If you write your variables names used in other file on a paper and will look at it periodically you will have less problems with them. :)

I'd like to use XML in your case. But it takes time to study.
0
 

Author Comment

by:klia
ID: 6162574
hi kmv,

if using XML, how the implementation like?

since I'm learning asp, why not learn it the rite way? :-)

cheers,
klia
0
 
LVL 2

Accepted Solution

by:
kmv earned 10 total points
ID: 6166857
You will create XML content on a flow - like you do HTML text in asp page. In XML file you will use some schemas to describe your data. You can use your own DTD (Data Type Definitions) or any existing. And you have to describe how to show your data using CSS or XSL. Usualy CSS and XSL are static pages.

It takes some time to learn.
XML:  http://www.w3.org/XML/
XSL:  http://www.w3.org/Style/XSL/
But I think you'd better use SSI (#include) first and then learn XML.

Good Luck!
0
 
LVL 2

Expert Comment

by:kmv
ID: 6180455
Thank you.
Best regards.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now