Yeah, Still Must be An Idiot

Results 1 to 4 of 4

Thread: Yeah, Still Must be An Idiot

  1. #1
    Paul the new guy Guest

    Default Yeah, Still Must be An Idiot

    OK, got a response early this morning (thanks again Darren) but still can&#039t make sense of it all.<BR><BR>When I plug specific data into this line:<BR><BR>Sql = "SELECT * FROM Dealers WHERE State=&#039CA&#039 ORDER BY City"<BR><BR>I can sort using ORDER BY with no problems. However, I&#039m using a search form, and for whatever reason, the following code is what seems to work for my drop down menu to pass a state along and display the results. I&#039m new to sql queries and pieced this together from examples:<BR><BR>mystate=request.querystring("st") <BR>SQL = "select * from Dealers where State=&#039" <BR>SQL = SQL & mystate & "&#039" <BR><BR>However, now I can&#039t seem to make my ORDER BY work in this statement. Guess I don&#039t get the single quote vs double quote, and where the ORDER BY should go, and what&#039s the proper use of quotes throughout the entire line that it populates.<BR><BR>If anyone can clear this up, point me in the right direction, or spell out the query for me, I&#039d appreciate it. Also, if there is a better use of a query for this purpose, I&#039m game.<BR><BR>Thanks again in advance,<BR><BR>Paul

  2. #2
    Steve Cimino Guest

    Default RE: Yeah, Still Must be An Idiot

    Single quotes are just telling SQL you are using string data, the same as when you use " to tell VB you are using string data. YOu place your order by clause after your last WHERE statement.<BR><BR>SQL = "SELECT * FROM Dealers WHERE State = &#039" & mystate & "&#039 ORDER BY City"<BR><BR>Quit concatenating the string each line. I&#039ve seen this done many times, but can&#039t figure out why. String concatenation in VBScript is absolutely horrendous.

  3. #3
    Join Date
    Dec 1969

    Default RE: Yeah, Still Must be An Idiot

    Single Quotes are used to delimit string values INSIDE the sql string that is sent to the server. Double quotes are used to delimit String values in ASP. <BR><BR>sSql= "SELECT BLah FROM Blah WHERE Fld = &#039Test&#039" <BR>Set rs = Connection.Execute(sSql) <BR><BR>SELECT BLah FROM Blah WHERE Fld = &#039Test&#039 is what is sent to the database. <BR><BR>ORDER BY should almost always be the last part of you statement ..<BR><BR>mystate=request.querystring("st")<BR>SQL = "select * from Dealers where State=&#039" <BR>SQL = SQL & mystate & "&#039" <BR>SQL = SQL & " ORDER BY State" <BR><BR>Notice the Space B4 ORDER ...<BR><BR><BR><BR>

  4. #4
    Paul (the new guy) Guest

    Default YES, The Idiot Get's An Answer

    Steve & G-mny<BR><BR>THANK YOU both for your input, I&#039m in business, and I also now understand a little more what these things mean.<BR><BR>I truly appreciate your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts