hi itsme
hi itsme

Reputation: 445

How do I set up SQL Server LocalDB to run on a client's machine?

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

Answers (1)

Virat Singh
Virat Singh

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

Related Questions