Solved

Urgent -Using Escape characters in my query- Please help

Posted on 2006-06-12
4
211 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
  • 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
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.
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now