I am trying to connect to sql server database .
I wrote vb.NET code to connect to database using bellow con. string:
"Server=ABOODPC\aboodsrvr; Database=testDB1;Integrated Security=SSPI;"
when converting the code into c# , I get the problem as shown in the title .
The problem is that \a
is being seen as an escape sequence (for "alert", U+007). The simplest approach is to use a verbatim string literal instead:
@"Server=ABOODPC\aboodsrvr; Database=testDB1;Integrated Security=SSPI;"
Alternatively, just double the backslash:
"Server=ABOODPC\\aboodsrvr; Database=testDB1;Integrated Security=SSPI;"
... or stop storing your connection string directly in your source code at all, of course...
See more on this question at Stackoverflow