Instance failure

There I was, minding my own business, encrypting my configuration files in the web.config like a good boy, and I got this message when I tried to open a SqlConnection object:

Instance failure

Luckily it didn’t take too long to find out what the problem was. An article on Scott Hanselman’s site showed me the solution. My connection string initially looked fine:

Data Source=.\\SQLEXPRESS;AttachDbFilename='C:\\Documents and Settings...

But, the problem were the double backslashes were turning into quadruple backslashes when I viewed it in the debugger:

Data Source=.\\\\SQLEXPRESS;AttachDbFilename='C:\\\\Documents and Settings...

That can’t be good. Once I changed the connection string to use single backslashes instead of double, all was well in my world again:

Data Source=.\SQLEXPRESS;AttachDbFilename='C:\Documents and Settings...
Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: