Stacie
asked on
unrecognized escape sentence - Connection string
I get an error on the backslah that say unrecognized escape sentence on SVSQ02\macomb_test
not sure why....
con = new SqlConnection("Data Source=SVSQ02\macomb_test;Initial Catalog=DropDown;Integrated Security=True");
con.Open();
not sure why....
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Two solutions:
1. The escape sequence for backslash is \\
con = new SqlConnection("Data Source=SVSQ02\\macomb_test
2. Tell C# you don't want to use escape sequences in the string with the @ prefix:
con = new SqlConnection(@"Data Source=SVSQ02\macomb_test;
Bye, Olaf.
Edit: I'm almost sure you've already seen sample code using the @ prefix. It's often the better solution for things like paths, especially unc path starting with "\\\\server\\share" are worse readable than @"\\server\share".