943,568 Members | Top Members by Rank

Ad:
  • ASP Discussion Thread
  • Marked Solved
  • Views: 1287
  • ASP RSS
Feb 23rd, 2008
0

Syntax Error (input character)

Expand Post »
Hello

Every time i input the character ' and % in the textfield it generate an error in my query.

The error:
Syntax error in query expression 'Title LIKE '%' %%';'.

My code:
asp Syntax (Toggle Plain Text)
  1. adoList.Open "SELECT * FROM qryOPAC WHERE Title LIKE '%" & varExp & "%';",CoNN,3,3



tnx in advance..
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
werks is offline Offline
57 posts
since Jan 2008
Feb 24th, 2008
0

Re: Syntax Error (input character)

The wildcard characters can be different depending on what database in use.

Try using the * character and see if it works better. Also try to set a static value and and see if you get any results from the database as WHERE Title LIKE '%someword%'
or
WHERE Title LIKE '*someword*'
Reputation Points: 10
Solved Threads: 3
Junior Poster
TobbeK is offline Offline
190 posts
since Feb 2008
Feb 25th, 2008
0

Re: Syntax Error (input character)

Also you missed the 2nd ' in your code
Reputation Points: 16
Solved Threads: 16
Junior Poster
Auzzie is offline Offline
121 posts
since Nov 2007
Feb 26th, 2008
0

Re: Syntax Error (input character)

The reason why it is coming up this way is that varexp is set to this:
ASP Syntax (Toggle Plain Text)
  1. ' %

check what varexp's value is and make sure you have NO quotes in there whatsoever, as well as % signs.
Reputation Points: 43
Solved Threads: 68
Veteran Poster
SheSaidImaPregy is offline Offline
1,080 posts
since Sep 2007
Feb 27th, 2008
0

Re: Syntax Error (input character)

Thanks for your reply. I just found out how to manage that by using Replace() function.. btw thanks everybody
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
werks is offline Offline
57 posts
since Jan 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP Forum Timeline: Dynamic XML
Next Thread in ASP Forum Timeline: ASP Virgin: Link Combo to Gridview





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC