Forum Moderators: open

Message Too Old, No Replies

New to Asp Quick Question

<%=Request.QueryString("mySTRING")%>

         

walker

7:42 pm on Jul 9, 2003 (gmt 0)

10+ Year Member



Hi

This will print what ever my?string was on the URL
<%=Request.QueryString("myString")%>

problem is I need to insert this inbetween a piece of code

EG:

<%

VARIOUS CODE FUNCTIONS
VARIOUS CODE FUNCTIONS
VARIOUS CODE FUNCTIONS

<%=Request.QueryString("salutation")%>

VARIOUS CODE FUNCTIONS
VARIOUS CODE FUNCTIONS
VARIOUS CODE FUNCTIONS

%>

when I do I get an error presumably because Im starting a new bracket in the middle of a function how do I get around this.

Kind Regards

Walker

TravelSite

7:46 pm on Jul 9, 2003 (gmt 0)

10+ Year Member



Just write the following:

Response.Write Request.QueryString("salutation")

The "=" is basically a shortcut for saying "Response.Write".

You can also do:

Response.Write "this is a nice day"

This will display text.

Finally, you can combine both of these by using the "&" sign:

Response.Write "Saluation is " & Request.QueryString("salutation")

Hope this helps

walker

8:09 pm on Jul 9, 2003 (gmt 0)

10+ Year Member



Hi

Thanks, I'm half way there but have now encouned a new problem

Here is the whole line ( currently prompting an error)

Set rstSimple = cnnSimple.Execute("SELECT * FROM employees WHERE FirstName= Response.Write Request.QueryString("salutation") ORDER BY EmployeeID")

Here is the hardcoded version that does work.

Set rstSimple = cnnSimple.Execute("SELECT * FROM employees WHERE FirstName= 'walker'ORDER BY EmployeeID")

I now assume its due to the double(

Any further assistance would really be appreciated.

Kind Regards

Rod

TravelSite

8:25 pm on Jul 9, 2003 (gmt 0)

10+ Year Member



Hi Walker,

I think it may work if you change the line to:

Set rstSimple = cnnSimple.Execute("SELECT * FROM employees WHERE FirstName=Request.QueryString("salutation") ORDER BY EmployeeID")

Also,

I sometimes find it makes things easier if you break it into two seperate statements (but I'm NOT sure if this works ok with the excute statements):

VarFirstName=Request.QueryString("salutation")
- the above line loads your value into a variable called VarFirstName.

Then:
Set rstSimple = cnnSimple.Execute("SELECT * FROM employees WHERE FirstName=VarFirstName ORDER BY EmployeeID")

walker

9:09 pm on Jul 9, 2003 (gmt 0)

10+ Year Member



Thanks,

I have tried both poss solutions and neither are being accepted. I really thorght that the var option would have done the trick.

Kind Regards

Walker

WebJoe

9:48 pm on Jul 9, 2003 (gmt 0)

10+ Year Member



You have to understand that the stuff between the brackets of
cnnSimple.Execute()
ist just a string (to asp). So in order to get your stuff to work, you should at least seperate your static part of the SQL statement from the variable as in

Set rstSimple = cnnSimple.Execute("SELECT * FROM employees WHERE FirstName= '" & VarFirstName & "' ORDER BY EmployeeID") 

or in a more readable form:


Dim strSQL
[...]
strSQL = "SELECT * FROM employees "
strSQL = strSQL & "WHERE FirstName= '" & VarFirstName & "' "
strSQL = strSQL & "ORDER BY EmployeeID"
cnnSimple.Execute(strSQL)

If your string-delimiter in SQL is a double quote (instead of a single quote as used in the above example), then the statement would be:


Dim strSQL
[...]
strSQL = "SELECT * FROM employees "
strSQL = strSQL & "WHERE FirstName= """ & VarFirstName & """ "
strSQL = strSQL & "ORDER BY EmployeeID"
cnnSimple.Execute(strSQL)

walker

8:40 am on Jul 10, 2003 (gmt 0)

10+ Year Member



WOW That works GREAT!

Thanks everyone for your help

Kind Regards

Rod

WebJoe

7:42 pm on Jul 10, 2003 (gmt 0)

10+ Year Member



:) glad I could help