Variables in a SQL Statement

Results 1 to 2 of 2

Thread: Variables in a SQL Statement

  1. #1
    Slowbob Guest

    Default Variables in a SQL Statement

    Having problems with a variable I am trying to use in one of my SQL statements, it keeps bringing up the following error message:<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e10&#039 <BR><BR>[Microsoft][ODBC Microsoft Access 97 Driver] Too few parameters. Expected 1. <BR><BR>/news/index2.asp, line 101<BR><BR>Here is the coding I am using, I have shown line 101 too:<BR><BR> &#060;% Dim objRS, strSQL<BR> <BR>strSQL = "SELECT * FROM news WHERE NewsMonth = " & ThisMonth2 & " ORDER BY NewsID DESC"<BR><BR> Set objRS = Server.CreateObject("ADODB.RecordSet")<BR> Line 101: objRS.Open strSQL, objConn<BR> <BR> Do While Not objRS.EOF<BR> Response.Write "&#060;B&#062;" & objRS("Snippit") & "&#060;/B&#062; " & objRS("NewsDate") & " : &#060;A HREF=news.asp?NewsID=" & objRS("NewsID") & "&#062;Read More&#060;/A&#062;&#060;HR&#062;"<BR> objRS.MoveNext<BR> Loop<BR>%&#062;<BR><BR>Please help! It works fine without the " & ThisMonth2 & " in the SQL Statement (I replace it with May and it works).<BR><BR>

  2. #2
    Rich Hoffman Guest

    Default RE: Variables in a SQL Statement

    You need to add a single quote after = and before order.

Posting Permissions

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