A
Alex
Hi all -
Is there a standard way to handle special chars in strings in dotnet? I'm
using csharp and having two seperate problems...
1. Passing in args...
I need to pass in an arg that points to a sqlserver2005 instance... it
comes in looking like this in the debugger:
I pass it in using this arg: MyServer\sql2005
In the debugger it displays as MyServer\\sql2005 - however it errors when I
try to make a dbconnection using it.
If I do this after receiving the arg, but before establishing the
connection then it still looks like MyServer\\sql2005 in the debugger, but
the connection is established.
sServer = sServer.Replace(@"\", "XXXXXXX");
sServer = sServer.Replace("XXXXXXX", @"\");
2. Special chars from the DB.
I have a DB field that I load into a string and then display in a textbox.
This field is allowed to have quotes. When I load it from the DB, it
displays the text (including the quotes) correctly as 'bang'.
However, when I write it back the ExecuteNonQuery fails since it tried to
build up the update string using the quotes without escaping them.
Is there a special string type I should be using to handle this, or do I
need to preprocess the string each time before building up my update
statment?
Seems like there should be a general way to handle special chars instead of
dealing with them all individually...
Thanks!
Is there a standard way to handle special chars in strings in dotnet? I'm
using csharp and having two seperate problems...
1. Passing in args...
I need to pass in an arg that points to a sqlserver2005 instance... it
comes in looking like this in the debugger:
I pass it in using this arg: MyServer\sql2005
In the debugger it displays as MyServer\\sql2005 - however it errors when I
try to make a dbconnection using it.
If I do this after receiving the arg, but before establishing the
connection then it still looks like MyServer\\sql2005 in the debugger, but
the connection is established.
sServer = sServer.Replace(@"\", "XXXXXXX");
sServer = sServer.Replace("XXXXXXX", @"\");
2. Special chars from the DB.
I have a DB field that I load into a string and then display in a textbox.
This field is allowed to have quotes. When I load it from the DB, it
displays the text (including the quotes) correctly as 'bang'.
However, when I write it back the ExecuteNonQuery fails since it tried to
build up the update string using the quotes without escaping them.
Is there a special string type I should be using to handle this, or do I
need to preprocess the string each time before building up my update
statment?
Seems like there should be a general way to handle special chars instead of
dealing with them all individually...
Thanks!