|
-
Jun 27th, 2007, 03:11 PM
#1
Thread Starter
Junior Member
Help with string "\"
Hy all
I have a conection string with SQL : string sConnection= "server=NB60\SQLEXPRESS;database=x;uid=a;pwd=;"
the problem is with the "\" from the name of the server name
can sombody tell me how i can write the string "\" to be corectly
-
Jun 27th, 2007, 03:15 PM
#2
Re: Help with string "\"
Either:
Code:
string sConnection= @"server=NB60\SQLEXPRESS;database=x;uid=a;pwd=;"
Or:
Code:
string sConnection= "server=NB60\\SQLEXPRESS;database=x;uid=a;pwd=;"
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Jun 27th, 2007, 06:17 PM
#3
Addicted Member
Re: Help with string "\"
What is happening is C# is reading the '\' as an Escape Character. What you need to do, is, escape the escape character, to allow the string to be read properly...
-
Jun 27th, 2007, 10:34 PM
#4
PowerPoster
Re: Help with string "\"
 Originally Posted by effekt26
escape the escape character
Easy way is that use @ sign, is it?
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
-
Jun 28th, 2007, 03:58 AM
#5
Lively Member
Re: Help with string "\"
I am clear about the problem.
For any special character like \ or ' you have to use an additional \ in c#
like \\ or \'
-Rajib
Please Rate every reply if it is useful to u
-
Jun 28th, 2007, 08:57 AM
#6
Hyperactive Member
Re: Help with string "\"
You could use the additional \ e.g. \\ or \' etc. But I think using the @ is a lot better, less typing and easier to understand for complex statements.
-
Jul 1st, 2007, 09:56 PM
#7
PowerPoster
Re: Help with string "\"
Traditionally/normally I used @ sign. Actually it use lots of people. So easy to understand.
“victory breeds hatred, the defeated live in pain; happily the peaceful live giving up victory and defeat” - Gautama Buddha
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|