Error in the WHERE clause when paging

Results 1 to 2 of 2

Thread: Error in the WHERE clause when paging

  1. #1
    Join Date
    Dec 1969

    Default Error in the WHERE clause when paging

    ************************************************** *************<BR>********I have a textbox in a form on my page1.asp:************<BR>************************ ***************************************<BR>&#060;F ORM&#062;<BR>&#060;INPUT id=txtBaniere name=txtBaniere&#062;<BR>&#060;input type="submit" value="OK" name="sub"&#062;<BR>&#060;/FORM&#062;<BR><BR>******************************** ********************************<BR>In my page2.asp I connect to my database and retreive the value of the textbox:<BR>************************************** **************************<BR>Dim varBaniere<BR>varBaniere = Trim(Request("txtBaniere"))<BR><BR>***********Conn ection*************<BR>Set conn = Server.CreateObject("ADODB.Connection")<BR>Set rs = Server.CreateObject("ADODB.Recordset")<BR>conn.Ope n "dsnname"<BR><BR>****************Query************ *****<BR>strSql = "SELECT Banniere.Ban_Definnition, Client.Num_Client, Client.Adresse1, Client.Num_Tel, Client.Num_Fax, Client.Nom_Legal, Demande.Num_Demande " & _<BR>" FROM (Banniere INNER JOIN Client ON Banniere.Cd_Banniere = Client.Cd_Baniere) INNER JOIN Demande ON Client.Num_Client = Demande.Num_Client WHERE "<BR><BR>If varBaniere &#060;&#062; "" Then<BR>strSql = strSql + "Banniere.Ban_Definnition LIKE &#039" + varBaniere + "%&#039"<BR>End if <BR><BR>rs.Open strSql, conn,adOpenForwardOnly ,adLockReadOnly <BR>********************************************** *******************<BR>Now if I enter the letter: j<BR>the query works find and i get all the information i wanted, since i&#039ve decided that i only want to show 10 records per page. I have a "next" and "previous" button. (I didn&#039t put the code of the paging in this example because it&#039s too long but trust me i&#039ve set it to 10 records/page)<BR><BR>Now when i do a response.write of my strSql statement I get:<BR>SELECT... WHERE Banniere.Ban_Definnition LIKE &#039j%&#039<BR><BR>Then I have a "next" button that apears since this query returns more than 10 records!<BR>The problem occurs when i click on that button i get an error message. The error message is:<BR>Microsoft OLE DB Provider for ODBC Drivers error &#039 80040e14&#039 <BR>[Microsoft][ODBC Microsoft Access Driver] Syntax error in WHERE clause. <BR>/Vlince/page2.asp line 53 <BR><BR>And the line 53 is:<BR>rs.Open strSql, conn,adOpenForwardOnly ,adLockReadOnly <BR><BR>The response.write of my query is:<BR>SELECT...WHERE<BR><BR>So the problem is when i click on the "Next" button it seems to me that the query looses the WHERE clause but why??? can you please help me!<BR>Thanks

  2. #2 Guest

    Default RE: Error in the WHERE clause when paging

    you get the where clause error when on of your values is empty<BR>like when you do this : select * from test where name = "&variable<BR>if variable is empty you get the where clause error<BR><BR>try searching for querystring or form bugs, they cause this a lot<BR><BR>greets<BR>Jeff

Posting Permissions

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