Simple SQL WHERE question...

Results 1 to 4 of 4

Thread: Simple SQL WHERE question...

  1. #1
    Marc E. Guest

    Default Simple SQL WHERE question...

    I can&#039t figure out why:<BR><BR>&#060;%<BR> Dim temp<BR> temp = "BBJ-GE"<BR> sql = "SELECT tblNextAvailProg.NextAvaiable FROM tblNextAvailProg where tblNextAvailProg.Program=temp"<BR> If cstr(Param) &#060;&#062; "" And cstr(Data) &#060;&#062; "" Then<BR> sql = sql & " WHERE [" & cstr(Param) & "] = " & cstr(Data)<BR> End If<BR>#33&#062;&#062; Set rs2 = Server.CreateObject("ADODB.Recordset")<BR> rs2.Open sql, conn, 3, 3<BR>%&#062;<BR><BR>Gives me:<BR><BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e10&#039 <BR><BR>[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1. <BR><BR>/org_submit.asp, line 33

  2. #2
    Join Date
    Dec 1969
    Posts
    29

    Default RE: Simple SQL WHERE question...

    Try response.write(sql) to see your sql statement... it looks like you may be including Where twice in the same sql statement...<BR><BR>sql = "SELECT tblNextAvailProg.NextAvaiable FROM tblNextAvailProg where tblNextAvailProg.Program=temp"<BR>If cstr(Param) &#060;&#062; "" And cstr(Data) &#060;&#062; "" Then<BR>sql = sql & " WHERE [" & cstr(Param) & "] = " & cstr(Data)<BR>End If<BR><BR>try changing this:<BR>sql = sql & " WHERE [" & cstr(Param) & "] = " & cstr(Data)<BR>to this:<BR>sql = sql & " and [" & cstr(Param) & "] = " & cstr(Data)<BR><BR>maybe this helps??

  3. #3
    Join Date
    Dec 1969
    Posts
    218

    Default RE: Simple SQL WHERE question...

    I changed it to:<BR><BR>&#060;%<BR> Dim temp<BR> temp = "BBJ-GE"<BR> sql = "SELECT tblNextAvailProg.NextAvaiable FROM tblNextAvailProg WHERE tblNextAvailProg.Program=temp"<BR> Set rs2 = Server.CreateObject("ADODB.Recordset")<BR> rs2.Open sql, conn, 3, 3<BR>%&#062;<BR><BR>And it doesn&#039t work! I get an error on the rs2... line... It&#039s <BR>not my database connection, becuase I used the same connection on some other scripts...

  4. #4
    Join Date
    Dec 1969
    Posts
    29

    Default RE: Simple SQL WHERE question...

    Change it to this... <BR><BR>&#060;%<BR>Dim temp<BR>temp = "BBJ-GE"<BR>sql = "SELECT tblNextAvailProg.NextAvaiable FROM tblNextAvailProg WHERE tblNextAvailProg.Program=&#039"&temp&"&#039"<BR>Se t rs2 = Server.CreateObject("ADODB.Recordset")<BR>rs2.Open sql, conn, 3, 3<BR>%&#062;<BR><BR>


Posting Permissions

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