Link to home
Start Free TrialLog in
Avatar of routerboy309
routerboy309

asked on

Passing SQL 7 and user added data over 4 pages

Using UD 4.01

I have 4 pages that gets data from a SQL7 database (passes using a combo box dropdown) and data from user entry (data collected using edit controls).

Since there is so much data that needs to get collected, I divided the collecting data up into four pages. I need to keep the data values alive until it gets to the last page and then it needs to be display in a table grid. This will give the user the ability to review the data prior to submitting it to the datatbase.

How do I keep the data live so it can pass from page to page until I get to the end? Examples, if possible.

DO I use a session variable? If so how do I set then when some of the content is going to be added by the user?

Thanks in advance.

rb
ASKER CERTIFIED SOLUTION
Avatar of Eric - Netminder
Eric - Netminder
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dclary
dclary

Best practices usually include being as sessionless as possible. But Eric Pete has the right answer.

In the pre-html portion of the 2nd page, read in the data from the post or get (whichever you're using) and Inset the SQL record. When you get the record number returned, be sure to set a hidden field its value, so you can retrieve it on subsequent pages.

(I use a stored procedure for the insert, so I can write code that returns the identity for me.

So if the user is  entering new data, page one is:

<%
'regular stuff
%>
<html>
<form with a bunch of fields>
</form>
</html>

Page 2 is

<%
sqlstring = "sp_insert "
sqlstring = sqlstring & request.form("field1") & ", "
sqlstring = sqlstring & request.form("etc") & " "
adors = adocon.openrecordset(sqlstring,0,1)
%>
<html>
<form>
<select type=hidden name=Myid value=<% =adors.fields(0).value %>>
<other form objects, blah blah>
</form>

On page 3... it's easy, you have the record number, so instead of inserting the record, update it:

sqlstring = "update mytable, set field2 = " & request.form("field2") & ", etal = " & request.form("etal") & " where IDField = " & request.form("MyID")
adocon.execute sqlstring

And finally, on page four, when you want to present all the entered data, simply retrieve it via the record number you've continued to pass along.

"Select * from mytable where IDfield = " & request.form("myid")


Hope this helps!
Avatar of routerboy309

ASKER

Ok - I see - carry the info over to the next and build the SQL statement as you go..

Thanks

RB