Unrecognized escape sequence \ C# error

The \ character is used as the escape character in C#. This lets you use
things like \n for the newline character. Thus to put a \ in a C# string
you need to use \\ for one \.

new SqlConnection("Data Source=.\\SQLEXPRESS;Integrated Security=True;")

Alternativly you can place an @ at the start of the string (before the
quote character) to tell C# not to use escape characters for this

new SqlConnection(@"Data Source=.\\SQLEXPRESS;Integrated


  1. I swear i have been searching for this answer from more than 5 hours!! thank you!!!


Post a Comment