Shanyman
Shanyman

Reputation: 41

Visual Studio Install - Post-install where should I point local database connection string?

I have a major, two day head damaging question. I have a localDB for a desktop application coded in C#. The .mdf database file resides in the root directory for the application. When debugging in development this worked fine (using EF6). My connection string is as follows:

(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\LocalStorage.mdf;integrated security=True;connect timeout=30

Yet when i build an installer and point my application as the 'Project Output' something happens whereby I receive the error upon successful install...

An attempt to attach an auto-named database for file C:\Program Files\Company Name\Program\LocalStorage.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

It seems my database does not install to the location (it simply isnt there). I suspect the '|DataDirectory|' in conn string does not point to an internal.exe location? Help Please, im at my wits end.

Upvotes: 0

Views: 99

Answers (1)

PhilDW
PhilDW

Reputation: 20790

Most cases like this are dealt with by having a dialog in the application that describes things about the database. That includes the security connection (Windows Integration or not) and perhaps the db name and location. I'd ask about that in a SQL forum rather than an installation forum. Although some installs sometimes ask users for that kind of thing in a dialog, most users would rather get the install finished and then worry about the configuration.

Upvotes: 0

Related Questions