Click here to Skip to main content
15,887,302 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my winform my connectionstring like this...
<connectionstrings>
<add name="Money_Lending_Calculator.Properties.Settings.dbLoanCalculatorConnectionString"
connectionString="Data Source=My-PC\SQLEXPRESS;Initial Catalog=dbLn;User ID=sa;Password=123"
providerName="System.Data.SqlClient" />


and in client machine ,thier are in sql management studio,database engine name is .."My-PC\SQLEXPRESS"
BUT in my connection string give error " unrecognized escape sequence"

what should i do?

What I have tried:

i have tried this string also,
<add name="Money_Lending_Calculator.Properties.Settings.dbLoanCalculatorConnectionString"
connectionString="Data Source=My-PC\\SQLEXPRESS;Initial Catalog=dbLn;User ID=sa;Password=123"
providerName="System.Data.SqlClient" />


THen on client side when user connect database engine like this as server name like this"My-PC\\SQLEXPRESS"

then error occured ..intance failure..and not connect with that name..
please tell me solution for this..in advance thanks...
Posted
Updated 1-Jan-18 1:05am
Comments
Richard MacCutchan 31-Dec-17 4:00am    
Where exactly in your code does that error occur?
Member 13275563 3-Jan-18 8:11am    
in app.config file
Member 13275563 3-Jan-18 8:10am    
in app.config file

1 solution

"\" is the so called 'escape' character, which means that the character following it will be interpreted as special character - if known... if no known you will receive the above error...
"My-PC\SQLEXPRESS"

In this string \S is considered to be an 'escaped' character, but unrecognized so you have the error...
To 'escape' the 'escape' character you have to double it...
 
Share this answer
 
Comments
Member 13275563 3-Jan-18 8:30am    
I HAVE USE WITH DOUBLE ESCAPE IN CONNECTIONSTRINGS,BUT IN CLIENT MACHINE ,IN THIER SQK MANAGEMENT STUDIO CANT CONNECT THAT DOUBLE CHARECTER

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900