Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to deploy a windows form application including database to another PC?

All

I have built a windows form application using VS 2005 Standard edition which uses SQL Express as the database.

I'd now like to deploy my application to another PC that has .NET framework and SQL Server already installed.

The bit I am unclear about is what do I need to do to ensure that my database is also deployed with my application?

I have spent most of the day reading various articles from msdn to other blogs and I can't get a clear understanding on what is the best way to deploy my application. Some of the varying advice includes:

  • Add a 'setup' project and create a setup.exe file
  • Use a custom action to create a database during installation (uses installer class)
  • Manually detach .mdf and .ldf from database and use command line on target PC to reattach to database
  • Amend .config file to get new connection string (from target machine) and then reference that in my ado.net code
  • etc. etc.

Can anybody cut through the confusion for me and help me out?

Thanks

like image 537
Alex P Avatar asked Nov 15 '22 13:11

Alex P


1 Answers

Here’s the simplest way I can think of:

  • Build the application
  • Copy the executable (in the Bin directory) and the app.config file to the other machine. The executable and app.config need to be in the same folder
  • Backup the database on your machine and restore it on the other machine
  • Change app.config to point to the restored database
like image 152
Carl Rippon Avatar answered Jan 16 '23 09:01

Carl Rippon