[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

unrecognized escape sequence

Posted on 2011-05-01
4
Medium Priority
?
733 Views
Last Modified: 2012-05-11
I am getting an using visual studio 2010 on my SQL Connection String called "Unrecognized escape sequence".  It is saying the dash between TOM-PC and SQLExpress is an unrecognized escape sequence.  Any suggestions on how I can resolve this?
      
public string connectionString="Data Source=TOM-PC\SQLEXPRESS;Initial Catalog=PIESACES2;Persist Security Info=True;User ID=PIESACES;Password=Amajor99";    
0
Comment
Question by:Hojoformo
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
mrjoltcola earned 2000 total points
ID: 35502260
Backslash is the escape char, so it thinks \S is an escape.

Change the string to a non-escaped one (add @)

public string connectionString= @"Data Source=TOM-PC\SQLEXPRESS;Initial Catalog=PIESACES2;Persist Security Info=True;User ID=PIESACES;Password=Amajor99";    

0
 
LVL 45

Expert Comment

by:AndyAinscow
ID: 35502860
Or use \\
Inside a string that is translated into a single \ character when string is not declared with an @ at the start (before the opening " mark)
0
 
LVL 15

Expert Comment

by:Navneet
ID: 35503135

Hi!

1. public string connectionString=@"Data Source=TOM-PC\SQLEXPRESS;Initial Catalog=PIESACES2;Persist Security Info=True;User ID=PIESACES;Password=Amajor99";
OR
2. public string connectionString=@"Data Source=TOM-PC\\SQLEXPRESS;Initial Catalog=PIESACES2;Persist Security Info=True;User ID=PIESACES;Password=Amajor99";

Thanks!
0
 
LVL 15

Expert Comment

by:Navneet
ID: 35503137
Hi!

1. public string connectionString=@"Data Source=TOM-PC\SQLEXPRESS;Initial Catalog=PIESACES2;Persist Security Info=True;User ID=PIESACES;Password=Amajor99";
OR
2. public string connectionString="Data Source=TOM-PC\\SQLEXPRESS;Initial Catalog=PIESACES2;Persist Security Info=True;User ID=PIESACES;Password=Amajor99";

Thanks!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question