ASP.NET - how to specify below string in double quotes at serverside???
Asked By mani on 24-Jan-12 09:26 AM
hi..i have below string that has to save as same indatabase..
rel="lightbox-cats"
how to place this as string in double quotes????
Riley K replied to mani on 24-Jan-12 10:31 AM
Specify it like this
string str = "\"lightbox-cats\".";
Console.WriteLine(str);
Console.ReadLine();
D Company replied to mani on 24-Jan-12 10:41 AM
Hello Friend,
You have to do 2 things
1. first place the string as follows
string str = "\"lightbox-cats\".";
2. Column data type should be NVARCHAR
Hope this will help you!!!
Regards
D
Sreekumar P replied to mani on 24-Jan-12 10:57 AM
Hi,
You can use the Escape Sequence for C# String ie. "\"
Escape Sequences
|
Escape Sequence
|
Represents
|
|
\a
|
Bell (alert)
|
|
\b
|
Backspace
|
|
\f
|
Formfeed
|
|
\n
|
New line
|
|
\r
|
Carriage return
|
|
\t
|
Horizontal tab
|
|
\v
|
Vertical tab
|
|
\'
|
Single quotation mark
|
|
\"
|
Double quotation mark
|
|
\\
|
Backslash
|
|
\?
|
Literal question mark
|
|
\ooo
|
ASCII character in octal notation
|
|
\xhh
|
ASCII character in hexadecimal notation
|
|
\xhhhh
|
Unicode character in hexadecimal notation if this escape sequence is used in a wide-character constant or a Unicode string literal.
For example, WCHAR f = L'\x4e00' or WCHAR b[] = L"The Chinese character for one is \x4e00".
|
Venkat K replied to mani on 24-Jan-12 12:07 PM
You need to use the escape sequence to pass double quote to database:
string height = TextBox1.Text.Replace("\"","\"\"").Replace("'","''");
Thanks