Re: Cannot seem to save a string with double quotes

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Ignacio Machin \( .NET/ C# MVP \) ("Ignacio)
Date: 04/26/04


Date: Mon, 26 Apr 2004 10:07:16 -0400

Hi Steven,

 If I understand correctly you want both the \ and the " to appear in the
string right?

What is happening is that \ is the "escape character" meaning that the next
character should not be interpreted as a especial char.
 So what \" gets converted in " and the \ is eliminated, cause it's used
only as a "escape"
 Now if you want the \ to appear you just simply "escape" it too :)
\\ will do the trick

Cheers,

-- 
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Steven Blair" <steven.blair@btinternet.com> wrote in message
news:uj3IBY5KEHA.988@TK2MSFTNGP11.phx.gbl...
> Hi,
>
> I need to update a DB Table (MySQL 4.0) with a string representing a
> directory path (C:\Temp\In) but cannot get C# to do this.
>
> I take the string value from a textbox (myStr = myText.Text) and pass
> this to a function.
>
> The function builds up a SQL string which will be executed:
>
> SQLString = String.Format( "UPDATE BSConfig " +
> "SET BSConfig_Inbound = \"{0}\",myStr);
>
> This puts the quotes round the text, but remvoes the slashes. I tried
> using the @ character (not sure what you call this lol) and the \" but
> was given an error.
>
> SQLString = String.Format( @"UPDATE BSConfig " +
> "SET BSConfig_Inbound = \"{0}\",myStr); //Not allowed
>
> Anyone help me out ?
>
> Regards,
>
> Steven
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!


Relevant Pages

  • Re: Escape character treatment in string library functions
    ... Can I change the escape character used by string libraries?. ... treat '\r' etc special making it difficult to parse even char by ...
    (comp.programming)
  • Re: RegEx and Vb.net /// "Unrecognized escape sequence"
    ... Not that \ is the escape character for regular expressions. ... VB.Net does not use the \ character as an escape character in strings. ... Dim fileName As String ...
    (microsoft.public.dotnet.framework)
  • Re: Unrecognized escape sequences in string literals
    ... If you don't know what your string literals are, ... Adding escape codes into the string literal doesn't change this ... extra effort required to defeat the compiler (forcing the programmer to ... And if you saw that in Python, you'd also know that there are some ...
    (comp.lang.python)
  • Re: Unrecognized escape sequences in string literals
    ... need worry that I've misinterpreted what a string literal means. ... You can't expect the compiler to save you from ... Adding escape codes into the string literal doesn't ... (This behavior is useful when debugging: if an escape sequence is ...
    (comp.lang.python)
  • Re: problems with opening files due to files path
    ... GUI or it is a console app. ... of what an escape character and escape sequence is. ... character) inside a string specially, it makes the character after the ...
    (comp.lang.python)