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

How to use URL variables

Status
Not open for further replies.
Jul 1, 2004
28
US
I am creating a page that retreives information from a query regarding a part number. The part number is passed to the page as a URL variable...Can someone help me with using the passed variable in a query string....I am not sure of the syntax.
Thanks!!!
 
Are you retrieving the part number from a database? Is it hard-coded into the page? (Dynamic or Static)?

If you are retrieving from a database:

strSQL = "SELECT * FROM db_partnumbers ORDER BY part_number;"
Set objRS = objConn.Execute(strSQL)
If objRS.EOF Or objRS.BOF Then
'Whatever you want it to do if there are no part numbers
Else
objRS.MoveFirst
Do While Not objRS.EOF Or objRS.BOF
vPartNumber = objRS.Fields("part_number")
Response.Write "<a href=""/YourURL/YourPage.asp?pn=" & vPartNumber & """>" & vPartNumber & "</a><br />" & vbcrlf
objRS.MoveNext
Loop
End If

Then, on your "YourPage.asp":

vPartNumber = Request.QueryString("pn")

 
OK, But how do I use that vPartNumber in a query on "YourPage.asp"... I am getting an error when this is coded...

Dim part
part = Request.QueryString("partNo")

Set rsWhereUsed = Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT ProductID, ParentID, QtyInParent, FROM Where_Used WHERE ProductID = part"...

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] The SELECT statement includes a reserved word or an argument name that is misspelled or missing, or the punctuation is incorrect.
/ops/Where_Used.asp, line 61


 
It should be :

Dim part
part = Request.QueryString("pn")


-VJ
 
Then in your query:

strSQL = "SELECT ProductID, ParentID, QtyInParent, FROM Where_Used WHERE ProductID = "&part

-VJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top