SQL problem in ASP page

Hi all,

I am working on a WAP project and am experiencing problems passing a variable to an SQL statement. The reason why I say this is that the variable appears to be storing the information as I can print this variable onto the screen, the staement is OK when I pass the information directly to the statement but this is not flexible for me. Below is the code:

<%@ Language = "JScript"; %>
<% Response.ContentType = "text/vnd.wap.wml" %>
<?xml version="1.0"?>
<!-- #include file="adojavas.inc" -->
<!DOCTYPE wml PUBLIC "-//OPENWAVE.COM//DTD WML 1.3//EN" "http://www.openwave.com/dtd/wml13.dtd">

<!-- London Attractions ASP file -->

<wml>

     <head>
          <meta forua="true" http-equiv="Pragma" content="no-cache"/>
          <meta forua="true" http-equiv="Cache-Control" content="no-cache, must-revalidate"/>
     </head>

           <%
               conn = Server.CreateObject("ADODB.Connection");
               rs = Server.CreateObject("ADODB.Recordset");
               lbrRs = Server.CreateObject("ADODB.Recordset");


               conn.Open("DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" +
                              Server.MapPath("city.mdb") + ";");

               //SQL Query
               initQuery = "SELECT LocationID, Name FROM Area";
                         
               rs.Open(initQuery, conn, adOpenForwardOnly, adLockReadOnly, adCmdText);
               
          %>

     <card id="area" title = "London Areas">
      <p>
        <b>The Attractions Page</b>
      </p>
      <p>
          <b>Please select the area you are visiting:</b><br/>

          <select name="area" title="Select Area">

          <%
               
               while (!rs.EOF)
               {
         
                    Response.Write("<option value=\" ");
                    Response.Write(rs("LocationID"));
                    //Response.Write(title=\" + rs("LocationID") + "\");
                    Response.Write("\">");
                    Response.Write(rs("Name"));
                    Response.Write("</option>");
                    rs.MoveNext();
               }
               
          %>

          </select>    
      </p>

       <do type="accept" label="OK">
          <go href="#venues" method="get">
               <postfield name="area" value="$(area)"/>
          </go>
       </do>

     </card>

     <card id="venues" title="Area Venues">
          <p>
               <b>List of venues:</b>
          </p>
          <p>

          <%

//Below is where Im experiencing problems. Please help thanks.

          place = Request.QueryString( "area");
          lbrQuery = "SELECT * FROM Attraction WHERE LocationID=' &place& ' ";
          lbrRs.Open(lbrQuery, conn, adOpenForwardOnly, adLockReadOnly, adCmdText);


               Response.Write( place);

               while( !lbrRs.EOF) {
                    Response.Write( lbrRs( "Name") + "<br/>");
                    lbrRs.MoveNext();
               }

               conn.Close();
          %>
          </p>

     </card>

</wml>
jimbo1278Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Arthur_WoodCommented:
without knowning ANYTHING about yout table, I would suspect that LocationID is a NUMBER field, not a string, in which case, these lines:

 lbrQuery = "SELECT * FROM Attraction WHERE LocationID=' &place& ' ";
         lbrRs.Open(lbrQuery, conn, adOpenForwardOnly, adLockReadOnly, adCmdText);

will not work, as Access will try to find a LOCATIONID as a

 lbrQuery = "SELECT * FROM Attraction WHERE LocationID = " & place
         lbrRs.Open(lbrQuery, conn, adOpenForwardOnly, adLockReadOnly, adCmdText);

0
Arthur_WoodCommented:
or possibly,

lbrQuery = "SELECT * FROM Attraction WHERE LocationID = " + place;
lbrRs.Open(lbrQuery, conn, adOpenForwardOnly, adLockReadOnly, adCmdText);

0
jimbo1278Author Commented:
The LocationID is set as a text field, in the database its a 3 letter field to identify the area the attractions are in. ie LBR is London Bridge. Will the query work as it is ?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

adatheladCommented:
Hi,
Try this:

lbrQuery = "SELECT * FROM Attraction WHERE LocationID='"  & place & "'"

lbrRs.Open(lbrQuery, conn, adOpenForwardOnly, adLockReadOnly, adCmdText)

Cheers
0
Arthur_WoodCommented:
what do you mean by:

"the staement is OK when I pass the information directly to the statement but this is not flexible for me"

what is not FLEXIBLE?

what do you need?

AW

0
jimbo1278Author Commented:
If I said

lbrQuery = "SELECT * FROM Attraction WHERE LocationID='LBR'"

then this works but I have other 3 letter codes that I am passing the hope was that place would accept any 3 letter area code.




0
adatheladCommented:
jimbo,

does this not work?
lbrQuery = "SELECT * FROM Attraction WHERE LocationID='"  & place & "'"

Cheers
0
jimbo1278Author Commented:
I tired what you said but still the same problem its as if the quey doesnt read the variable
0
spongieCommented:
Change this:

lbrQuery = "SELECT * FROM Attraction WHERE LocationID=' &place& '"

to this:

lbrQuery = "SELECT * FROM Attraction WHERE LocationID='" & place & "'"

I think you have included the variable [place] within the quotes thus making it a literal
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
walterecookCommented:
This question has been classified as abandoned.  I will make a recommendation to the moderators on its resolution in approximately 4 days.  I would appreciate any comments by the experts that would help me in making a recommendation.

It is assumed that any participant not responding to this request is no longer interested in its final deposition.

If the asker does not know how to close the question, the options are here:
http://www.experts-exchange.com/help.jsp#hs5

walterecook
EE Cleanup Volunteer
0
walterecookCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Accept: spongie {http:#8328240}

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

walterecook
EE Cleanup Volunteer
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.