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

capturing the values from a form & using it in another page

Status
Not open for further replies.

ifeyinwa

Programmer
Mar 26, 2003
112
US
Thanks guys for yesterday of course the struggle continues.

*have my asp page1.asp here I have 2 forms on this page. In The first form on this page there is no actual texboxes etc just used the submit button put a link on it which takes you to another page.(just serving the purposed of a hyperlink).
the second form is a proper form with a drop down box.The drop down box is populated with fields from the database table. Now when the user picks an option from the drop down this is what I want to happen.

On page1.asp
* The information selected by the user from the drop down box is retrieved/captured which represents a record in the database.
when the submit Button is hit I want it to open another page -page2.asp- where the fields in the database for that record the user selected from the drop down is displayed for the user to update.

This is how I set out to capture the value from the drop down in the form -page1.asp-

Session(userbill) = Request.form("BILLNO") also with the

<form method="POST" action="page2.asp"

In -page2.asp- this is my scripting


<%

Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("adodb.Recordset")
Conn.Open "eiwp"
SQLQuery = "Select * from tblopgaCOm2 WHERE billNo = " & Session(userbill)
RS.Open SQLQuery ,Conn,1,1

but it is given me THESE errors


"Session object error 'ASP 0102 : 80004005'

Expecting string input

/eiwp/audit.asp, line 63

The function expects a string as input".

A RESPONSE APPRECIATED AS ALWAYS

 
Try this:

SQLQuery = "Select * from tblopgaCOm2 WHERE billNo = '" & Session(userbill)&"' "

-VJ
 
still get the same error which says its from the first page page1.asp and exactly from this line script

Session(userbill) = Request.form("BILLNO")

--so I reckon this must be a wrong way to capture the details???
 
Try this:

Session("userbill") = Request.form("BILLNO")

-VJ
 
and then in the query use:

SQLQuery = "Select * from tblopgaCOm2 WHERE billNo = '" & Session("userbill")&"' "

-VJ
 


okay have no more errors with the 1st page page1.asp
however I have added another line in my sql statement to narrow down the search cause the billno can be identical but area makes it unique.
like I said 1st page is okay now I used the

Session("userbill") = Request.form("BILLNO")
and it came back free of errors.
Now with the slight change below I get this error

"Microsoft OLE DB Provider for ODBC Drivers error '80040e21'

ODBC driver does not support the requested properties.

/eiwp/audit5.asp, line 23"





<%

Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("adodb.Recordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE "
SQLQuery = SQLQuery & "billNo = '" & Session("userbill")&"' "
SQLQuery = SQLQuery & "AND area LIKE 'AUDIT' & "'"
RS.Open SQLQuery ,Conn,1,1

%>
 
Try this:

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("adodb.Recordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE "
SQLQuery = SQLQuery & "billNo = '" & Session("userbill")&"' "
SQLQuery = SQLQuery & "AND area LIKE 'AUDIT' "
RS.Open SQLQuery ,Conn,1,1
%>

OR

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("adodb.Recordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE "
SQLQuery = SQLQuery & "billNo = '" & Session("userbill")&"' "
SQLQuery = SQLQuery & "AND area = 'AUDIT' "
RS.Open SQLQuery ,Conn,1,1
%>

OR

<%
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("adodb.Recordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE "
SQLQuery = SQLQuery & "billNo = '" & Session("userbill")&"' "
SQLQuery = SQLQuery & "AND area LIKE '%AUDIT%' "
RS.Open SQLQuery ,Conn,1,1
%>


 
Try this . . .

SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '" & Session("userbill") & "' AND area LIKE 'AUDIT'"

----------------------------
SnaveBelac - Adventurer
----------------------------
 
All the above combinations seem to work. I get no more errors on that sql line. BUT this is error message I now get

ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/eiwp/audit5.asp, line 0
 
That is because there are no records matching your criteria. I mean the error says that they are no records related to the billno AND area selected together.

Try to run the query in the query analyzer and see the results.

If you want to avoid the error then do this:

If RS.EOF Then
Response.Write "No Records Found"
Else
Show your results.
End IF

-VJ

 
The query Analyser does not seem to like this
WHERE billNo = '" & Session("userbill") & "' AND area LIKE 'AUDIT'"
I gues sit does not know what Session("userbill") refers to????
 
o'boy

Try this faq333-4896 ifeyinwa

Let us know how it turns out

___________________________________________________________________

The answer to your ??'s may be closer then you think. faq333-3811
Join the Northern Illinois/Southern Wisconsin members in Forum1064
 
You cannot try the query as it is in query analyzer.

You have to replace the variables with the respective values and then try it QA.

Try something like this in the QA:


SELECT * FROM yourdatabasename.dbo.tblopgaCOm2 WHERE billNo = 'userbillone' AND area LIKE 'AUDIT'"

where Session("userbill") = userbillone for example...


-VJ
 
OKAY i TRIED THIS BELOW IN THE QA AND i GOT NO ERRORS i GOT THE RECORDS FROM THE QUERY SO NOW HOW DO iPLUG THIS INTO MY ASP SCRIPT?????

SELECT * FROM tblopgaCOm2 WHERE billNo = 'HB0124' and area = 'AUDIT'
 
ok thats good..

Now when you try this using ASP, select the billNo as HB0124 from the drop box and set the area to Audit.

So when you select billNo, your session variable would be

Session("userbill")=HB0124

Now do the same query

SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '" & Session("userbill") & "' AND area LIKE 'AUDIT'"

Also write out your query to check if everything gets populated correctly using Response.Write

Response.Write SQLQuery <-- add this line to your code.

-VJ
 
this is my error message
SELECT * FROM tblopgaCOm2 WHERE billNo = '' AND area LIKE 'AUDIT'

Tracking Comments

Comment on a Bill and hit the submit button


ID#:
ADODB.Field error '80020009'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/eiwp/audit5.asp, line 0

 
From the query we see that your session variable is not getting populated correctly.

Try this:

before querying

Response.Write Request.Form("BILLNO")

Then do

Session("userbill")=Request.Form("BILLNO")

Now check again to see if the value is passed correctly.

Response.Write Session("userbill")

-VJ

 
DO I do this on the istpage where the drop down box is or do I do this on the second page.
 
Second page...

Hmm ok

why dont you paste the code for your both pages .

-VJ
 
THESE ARE MY CODES FOR THE 1ST AND 2ND PAGES

asp code for first page

<%
'get form details and declare variables
Session("userbill") = Request.form("BILLNO")

'set the connections
Set Conn = Server.CreateObject("ADODB.Connection")
Set RS=Server.CreateObject("ADODB.RecordSet")
Conn.Open "eiwp"
SQLquery = "Select billNo from tblopgaCom2 where area LIKE 'AUDIT' order by reqDate asc"
RS.Open SQLquery, Conn
If RS.EOF then
Response.write "<center>There are no records in the table"
Respose.write "<br>please check back later</center>"
Response.end
Else
%>
<p><select size="1" name="BILLNO">
<option>-Select One-</option>
<%
DO WHILE NOT RS.EOF
%>
<option value="<%Response.Write RS("billNo")%>"><%Response.Write RS("billNo")%></option>
<%
Rs.MoveNext
Loop
End If
%>
</select></td>
<%

Rs.close
Set RS = Nothing

Conn.Close
Set Conn = Nothing



%>

<td width="69">
<input type="submit" value="Submit" name="B1"></p>
</form>



ASP CODE FOR THE SECOND PAGE

<%

Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("adodb.Recordset")
Conn.Open "eiwp"
SQLQuery = "SELECT * FROM tblopgaCOm2 WHERE billNo = '" & Session("userbill") & "' AND area LIKE 'AUDIT'"
RS.Open SQLquery, Conn

%>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top