Solved

Urgent -Using Escape characters in my query- Please help

Posted on 2006-06-12
4
216 Views
Last Modified: 2010-04-23


I am trying to use the escape characters in my query and I am getting the syntax error as
Incorrect syntax near 'Ifft & Co., P.A.'.  
Please help.


 strSQLQuery = "SELECT id,firm,residentmanager,address, city +', '+ state+', ' + zip as address2,phone,discipline,issuerenewdate,registrationexpiredate,certstatus FROM tblboadata where ksboatype ='" & "F" & "' and (firm LIKE('%'+Replace(Replace(Replace(Replace(Firm,'\', '\\'), '[', '\['), '_', '\_'), '%', '\%')+'%') ESCAPE '\')'" & sFirm & "'"
0
Comment
Question by:amruthanet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 17

Expert Comment

by:ZeonFlash
ID: 16887609
The end of your SQL string looks fishy:
       ESCAPE '\')'" & sFirm & "'"

That will put something like:  ESCAPE '\')'sFirmContents'

What is an example of what can be in sFirm?
0
 

Author Comment

by:amruthanet
ID: 16887939
Below are the examples for the querystring(sFirm)

Ifft & Co., P.A.
Schmidt & Eudaley CPA's, P.A.
Schulteis and Walsh, P.A.

So should I need to remove the single quote?

Thanks,
0
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 16888316
No need to remove the single quotes, just replace them with 2 single quotes.  Does the following work?

"SELECT id,firm,residentmanager,address, city +', '+ state+', ' + zip as address2,phone,discipline,issuerenewdate,registrationexpiredate,certstatus FROM tblboadata where ksboatype ='" & "F" & "' and firm LIKE '%" & sFirm.Replace("\", "\\").Replace("[", "\[").Replace("_", "\_").Replace("%", "\%").Replace("'", "''") & "%'"
0
 

Author Comment

by:amruthanet
ID: 16888623
Thanks a bunch.  It worked as a charm.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

691 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question