Create an installer for winForms with a local database

I have a Winforms application (a game with checkers) in which there is a local database (using SQL Server Express) to save registered players and their results.

I am trying to create an installer for this application using a tutorial

Everything is fine, but when I try to add players, I get an SQL error that the database was not found .. so how can I add a local DB ( .mdf file) to the installer?

+4
source share
2 answers

Provided that the conditions for using the local database on the client machine are in order (see Local deployment on the client PC ), in the deployment project you can simply add the database files to the application folder (select "File system editor" in the solution explorer when choosing the deployment project .

enter image description here

Side note: did you know that in VS2012 the MSI deployment project template is out of date?

Update: And this is back in VS 2013!

+4
source

This is my workaround in wpf . I think the solution is the same in Winform:

  • Make your mdf file “ content ” by right-clicking on it and select properties. From the build menu, select " content ." And in copy to directory select always copy

  • In Solution explorer, go to Properties / Settings. Settings and put the connection strings in the field (note that the name that should be the same as it is in your App.config (for example, in wpf), as shown in the figure below )

The connection string must be the same

  1. Right-click in the project and Add-> Project output → , then select the content files .
0
source

All Articles