Home All Groups Group Topic Archive Search About

quotation marks in string - how to add

Author
5 Jul 2006 6:20 PM
Ufit
Simple,dumm question - how to include quotation marks in the string?
F.ex. "Data Source=.\SQLEXPRESS;AttachDbFilename="C:\client data.mdf";Integrated Security=True;User Instance=True"
I get syntax error.
Thanks for help

Ufi

Author
5 Jul 2006 6:57 PM
Marina Levit [MVP]
You put them in twice.  So something like:

Dim s as String = "Double quotes around test: ""test"""

Show quoteHide quote
"Ufit" <kot_tmp0SPAMSPAM@NOpoczta.fm> wrote in message
news:e8gvt4$3nu$1@news.onet.pl...
> Simple,dumm question - how to include quotation marks in the string?
> F.ex. "Data Source=.\SQLEXPRESS;AttachDbFilename="C:\client
> data.mdf";Integrated Security=True;User Instance=True"
> I get syntax error.
> Thanks for help
>
> Ufi
Author
5 Jul 2006 7:30 PM
Jim Wooley
Another option:
   String.Format("Data Source=.\SQLEXPRESS;AttachDbFilename={0}C:\client
             data.mdf{0};Integrated Security=True;User Instance=True", ControlChars.Quote)
Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx

Show quoteHide quote
> Simple,dumm question - how to include quotation marks in the string?
>
> F.ex. "Data Source=.\SQLEXPRESS;AttachDbFilename="C:\client
> data.mdf";Integrated Security=True;User Instance=True"
>
> I get syntax error.
>
> Thanks for help
>
> Ufi
>
Author
5 Jul 2006 7:53 PM
Herfried K. Wagner [MVP]
"Ufit" <kot_tmp0SPAMSPAM@NOpoczta.fm> schrieb:
> Simple,dumm question - how to include quotation marks in the string?
> F.ex. "Data Source=.\SQLEXPRESS;AttachDbFilename="C:\client
> data.mdf";Integrated Security=True;User Instance=True"
> I get syntax error.

Encode each quotation mark that should appear in the string as two
consecutive quotation marks:

\\\
s = "He said ""Hello World!"""
///

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>