programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Website by URL, How to Play YouTube Videos in by using Jquery , Jquery Change div background on mouseover in , JQuery UI Datepicker (Calendar) etc.

Wednesday, November 5, 2014

Unrecognized escape sequence in database connection string c#

Unrecognized escape sequence when we make connection string c#:

When we connect sql database in web site and make connection on page then many type we face this type of problem.

If you are new and you want to create connection at first time then it is possible that you face this problem.

Unrecognized escape sequence:

As we know that we write fallowing code for make connection.

string connetionString = null;
            SqlConnection cnn ;
                     connetionString = "Data Source=PARIJAT-PC\PARIJAT;Initial Catalog=my_testing;Integrated Security=True";

            cnn = new SqlConnection(connetionString);

And get an Exaction or Unrecognized escape sequence error. Because you do not use  \ (forward sales) in string object.

For solving this here we give two option.

  • Use @ with connectionstring as like :

connetionString = @"Data Source=PARIJAT-PC\PARIJAT;Initial Catalog=my_testing;Integrated Security=True";

  • Use \\ sales in the place of single sales. Like as :

connetionString = "Data Source=PARIJAT-PC\\PARIJAT;Initial Catalog=my_testing;Integrated Security=True"; related Other Post :

No comments:

Post a Comment