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

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

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

Related

Is there a way to password protect a SQL LocalDB .mdf file in C# application?

I am creating a C# WinForms desktop application along with a SQL Server LocalDB database. I have a setup installer to install the application on desktop. Since it is not on the web server, I have to put the db.mdf file on the customer's computer. But then the user may try to attach this database to SQL Server installed in their own PC and access the data from outside the application. Is there any way I can password protect the file so that it can only be accessed from the application?
I tried to change the extension of file so that it won't be oblivious that its an .mdf file but it does not work without .mdf extension.
Please help me if there is any way I can find a solution to this or any other database I can use for the purpose.

How to create a pre-packaged deployment script for a database project?

I have a DB project in Visual Studio and I need to deploy it to a remote system as a pre-packaged script (or similar) as a new database.
The Publish option will generate a .publish SQL script but only if you supply a connection first, and the script includes machine-local information e.g. logging paths.
I want something I can copy onto the DB-server machine running SSMS and it will create the DB. What is the proper way to do this, I see I also have DAC and DLL files emitted during build.
What is the proper way to do this?
Connect to a server that doesn't have any version of your database, and publish. Publish calculates an incremental deployment, so it needs to see the current state of the target SQL Server.

Create setup.exe included database (sql) in Visual Studio 2012

I have created a program in C# which is connected with the database in SQL server as localhost. When I create setup file with instalShield, the program successfully installed, but it doesn't show the data from database and as such can not be used fully.
Can you help me what should I do to make a full setup.exe which can install everywhere including all files and database?
You can use from setup factory soft ware .
It's powerful for create setup.
http://download.cnet.com/Setup-Factory/3000-2216_4-10002374.html

How can I copy Dll's to Program Files folder in Windows 2008 Server using C#

We already have a C# application for Deploying Dll's to different environments(DEV/QA/PROD). This application when asked copies the required Dll's to Program Files folder. This was working fine in Windows 2003 server. But now we migrated our server environments to Windows Server 2008 which brings UAC into picture.
Now when we try to copy the Dll's from local desktop to Server Program files using our application the application is failing.
Can any one suggest me what is the C# code that can make my application to elevate it privileges which allows me to copy the Dll's to remote server.
Regards
Masthan
Add an application assembly manifest that includes requestedExecutionLevel of requireAdministrator.
That way your update program will be run as an administrator.
You could also change your installer to give all users Full Control to your application folder; that way any user could modify your application.

How to install a custom desktop application database to SQL Express?

I have a WPF desktop application that uses a custom database for storage.
I need to prepare a setup project (from Visual studio 2008) (full setup, not ClickOnce).
I can add the to the list of prerequisites to the application and it does install during the setup of the application.
My question is: How can I run a script during the setup to create the database that the application needs? OR how can I restore the database to the client machine during the setup?
Another related question, what would happen if already exists on the client machine? How to detect the instance name and connection data? And then how to be able -if needed- to change the Connection string used by Entity framework to connect to that database?
Thanks,
Ed
SQL Server Express Edition is generally a really poor choice for a local database. It's a server-class engine that likes to use a lot of resources and runs as a service (so it's using up those resources even when your app isn't running). In other words, it belongs on a server.
The only place I've seen SQL Server Express used on a desktop that almost makes sense is as part of the Microsoft Small Business Accounting app, and in this case you generally install that program on a machine who's primary purpose is doing the accounting for your business.
What you should do is use a desktop or in-process class engine like SQL Server Compact Edition, Sqlite, or even Access. This will also greatly simplify your deployment.
If you insist on pushing through with this, know that the installer will create a new instance of sql server on the system. SQL Server will be fine with this. However, you'll need to account for that in the connection string of your app, and that can be a little more complicated. Additionally, to set up the database you have a couple options:
Create it from client code on first start of the app
Create it with a custom installer action (hard to get right because msi permissions)
Distribute an pre-build *.mdf file and attach with custom installer action or on first start of the app.

Resources