Solved

Urgent -Using Escape characters in my query- Please help

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Encryption Decryption in Oracle 12 107
help with issues with ReportViewer in VS2015 5 38
Recommendation vb6 to vb.net or others 14 111
Help with Syntax 9 27
This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

13 Experts available now in Live!

Get 1:1 Help Now