Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Re: Help needed with URLdecoding a recordset filter var


Message #1 by "Philhouse" <spam@t...> on Tue, 4 Feb 2003 06:15:08
Any values passed in via the QueryString object should automatically 
be "URLDecoded."  I assume you mean converting %20 and + to spaces, etc.  
If that's the case it should just be a simple matter of referencing the 
value in the querystring.... assuming the value was encoded properly (ie: 
Server.URLEncode(x))

Dim x

x = Request.QueryString("x")

sSQL = "SELECT * FROM Products WHERE ProductCat LIKE '" & x & "'"
oRS.Open sSQL, oConn, adOpenForwardOnly, adLockReadOnly
for each field in oRS.Fields
  Response.write field.Name & ": " & field.Value & "<br>"
  oRS.MoveNext
next

I hope I'm understanding what you're getting at there...

Clear Skies



> I'm designing using Dreamweaver MX and have found a need to hand-code
(unfortunately I'm no ASP expert)...  I need to URLdecode a variable passed
in to me but can't find a way of doing it.  The recordset code shown below
is what I want to change, the ProductSubCat variable being the one I want 
to
decode.

How do I do it?

<%
var jg__Cat = "%";
if(String(Request.QueryString("ProductCat")) != "undefined") {
  jg__Cat = String(Request.QueryString("ProductCat"));
}
%>
<%
var jg__Subcat = "%";
if (String(Request.QueryString("ProductSubCat")) != "undefined" &&
    String(Request.QueryString("ProductSubCat")) != "") {
  jg__Subcat = String(Request.QueryString("ProductSubCat"));
}
%>
<%
var jg = Server.CreateObject("ADODB.Recordset");
jg.ActiveConnection = MM_jgcollection_STRING;
jg.Source = "SELECT *  FROM Products  WHERE ProductCat like '"+
jg__Cat.replace(/'/g, "''") + "'  AND ProductSubCat like '"+
jg__Subcat.replace(/'/g, "''") + "'  ORDER BY ProductName";
jg.CursorType = 2;
jg.CursorLocation = 2;
jg.LockType = 1;
jg.Open();
var jg_numRows = 0;
%>

Thanks in advance for any help given!

GP



  Return to Index