Reputation: 445
I'm using Winforms and SQL Server LocalDB to develop an application that will be installed to an end user's desktop.
I tried the following connection string:
string config = "Server=(localdb)\v11.0; Integrated Security=true; AttachDbFileName=C:\\Folder\\dbName.mdf;";
I get the following error:
an error ocorred.. cannot connect to SQL SERVER...Provider:Named Pipes Provider, error 40 ...."
Upvotes: 2
Views: 1306
Reputation: 61
You need to add two backslashes before v11.0 or add @ at the beginning on your statement. So, your connection string will be:
string config = "Server=(localdb)\\v11.0; Integrated Security=true; AttachDbFileName=C:\\Folder\\dbName.mdf;";
or
string config = @"Server=(localdb)\v11.0; Integrated Security=true; AttachDbFileName=C:\\Folder\\dbName.mdf;";
Upvotes: 1