Syntax error in FROM clause

Results 1 to 6 of 6

Thread: Syntax error in FROM clause

  1. #1
    Join Date
    Dec 1969
    Posts
    730

    Default Syntax error in FROM clause

    Hello,<BR><BR> I have tried and tried, but I keep getting a syntax error in my sql statement.<BR><BR>strRegion = Request.QueryString("Region") <BR>strSQL = "SELECT * FROM [membersrides] WHERE Region = " & strRegion & "" <BR>Response.Write strSQL<BR>set objRSTemp = Server.CreateObject("ADODB.Recordset") <BR>objRSTemp.open strSQL, objConn, , , adCmdTable <BR><BR> As you can see, I have used Response.Write to see the output of my code, and it seems right. This is what is wrote to the page:<BR><BR>SELECT * FROM [membersrides] WHERE Region = Minnesota <BR><BR>

  2. #2
    Join Date
    Dec 1969
    Posts
    1,505

    Default RE: Syntax error in FROM clause

    well u r missing single quotes around the variable, any string variable has to be enclosed in quotes, change the sql to this:<BR>**<BR>"SELECT * FROM [membersrides] WHERE Region=&#039;" & strRegion & "&#039;" <BR>**<BR>see the introdution of single quotes before "=" and in the end?<BR>

  3. #3
    Join Date
    Dec 1969
    Posts
    730

    Default Still get a sytax error

    Thank you for that advice. I had tried that before, with no luck. This is the error message I get with that line:<BR><BR>Microsoft JET Database Engine error &#039;80040e14&#039; <BR>Syntax error in FROM clause. <BR>/members/admin_viewinfo.asp, line 14 <BR><BR><BR>this is the code I am using, line 14 is the last line:<BR><BR>strRegion = Request.QueryString("Region") <BR>strSQL = "SELECT * FROM [membersrides] WHERE Region=&#039;" & strRegion & "&#039;" <BR>set objRSTemp = Server.CreateObject("ADODB.Recordset") <BR>objRSTemp.open strSQL, objConn, , , adCmdTable

  4. #4
    Join Date
    Dec 1969
    Posts
    1,505

    Default RE: Still get a sytax error

    would like to see the whole code, u sure the strregion is coming in as a querystring and not as a request object, show me how the region is coming from the previous page.


  5. #5
    Join Date
    Dec 1969
    Posts
    1,505

    Default also..

    instead of opening the sql and the conn just execute the sql as:<BR>set objrs = strconn.execute(strsql)<BR>see what this gives u.

  6. #6
    Join Date
    Dec 1969
    Posts
    730

    Default Heres the code

    This is on PWS, so don&#039;t try to check out the link, thats just there to show the querystring:<BR><BR><BR>http://web-geek/members/admin_viewinfo.asp?Region=Minnesota<BR><BR><BR>&#0 60;!--#include virtual="/top.asp"--&#062;<BR>&#060;!--#include file="opendb.asp"--&#062;<BR><BR>&#060;%<BR>Dim objRSTemp <BR>dim strRegion<BR>dim strSQL<BR>strRegion = Request.QueryString("Region") <BR>strSQL = "SELECT * FROM [membersrides] WHERE Region=&#039;" & strRegion & "&#039;" <BR>Response.Write strSQL<BR>set objRSTemp = Server.CreateObject("ADODB.Recordset") <BR>objRSTemp.open strSQL, objConn, , , adCmdTable<BR><BR><BR>This is what i get when loading the page with line 14 being the last line above(with the response.write):<BR><BR>SELECT * FROM [membersrides] WHERE Region=&#039;Minnesota&#039; <BR>Microsoft JET Database Engine error &#039;80040e14&#039; <BR>Syntax error in FROM clause. <BR>/members/admin_viewinfo.asp, line 14

Posting Permissions

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