Hello tech
Hello tech

Reputation: 13

MS SQL SERVER 2008r2 connection with Visual studio 2012

SqlConnection con = new SqlConnection("Data source=BIMESH-PC\SQLEXPRESS;initial catalog=LibrSystem;integrated security=true");

In this code the escape sequence is not acceptable. please rectify this code.

Upvotes: 1

Views: 1043

Answers (1)

Adriaan Stander
Adriaan Stander

Reputation: 166316

You could try either

SqlConnection con = new SqlConnection(@"Data source=BIMESH-PC\SQLEXPRESS;initial catalog=LibrSystem;integrated security=true");
SqlConnection con = new SqlConnection("Data source=BIMESH-PC\\SQLEXPRESS;initial catalog=LibrSystem;integrated security=true");

You should have a look at verbatim string literals, and escaped string literals

Upvotes: 1

Related Questions