Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Urgent -Using Escape characters in my query- Please help

Posted on 2006-06-12
4
Medium Priority
?
218 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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

636 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