Advertisement

06.19.2008 at 11:08AM PDT, ID: 23499942
[x]
Attachment Details

embedded quotation marks in a query

Asked by garyinmiami2003 in Sybase Database, Microsoft Visual Basic.Net

Tags: vs 2005, 2005, vb.net

suppose I have a table:  TABLE_A with a column Col1 char(20)

The value of row 99   for Col1 = "O'DONELL"

Now I construct a dynamic query using a txtBox1.Text = "O'DONELL"    
My query:
dim strSQL = " Select * from dbo.TABLE_A WHERE Col1 = ' " &  txtBox1.Text & " ' ".

I purposely put extra spaces to see the quotes & double quotes better.  The above statement will fail because of the embedded ( ' ) in the txtBox1 variable.  I think an update or insert query may work by replacing the 1 single quote with 2 single quotes but I have found that this does not work for me when it is in a where clause.  Please include a code sample with your solution.

Start Free Trial
[+][-]06.19.2008 at 11:23AM PDT, ID: 21824908

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.19.2008 at 11:26AM PDT, ID: 21824939

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.19.2008 at 11:35AM PDT, ID: 21825026

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Sybase Database, Microsoft Visual Basic.Net
Tags: vs 2005, 2005, vb.net
Sign Up Now!
Solution Provided By: Hendo1973
Participating Experts: 3
Solution Grade: A
 
 
[+][-]06.19.2008 at 11:41AM PDT, ID: 21825075

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]06.19.2008 at 11:45AM PDT, ID: 21825129

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628