How to generate database backend during software installation?

I have developed a small application with support for SQL SERVER, and I am also an installer for an application with Indigo Rose Setup factory 8.0. I need me to automatically create the back end of the database with a specific user account during application installation.

Before the installer, the user is prompted to install SQL Server or SQL express as a prerequisite, when the database is installed, the software installation continues. I tried to use a SQL script, but I do not know how to do this before installing the installer on the software. I would also like to embed the database creation program in the main application and execute it when the user needs it after the installation is completed, but I never tried it before it works or not.

If necessary, I developed a system using C # with SQL SERVER 2005 server. So, please, give me an answer to solve this problem? Thanks you

+3
source share
2 answers

The easiest way is to run the sqlcmd.exe installer to run the sql script. To call this, you need to know the data source (location) of the sql instance. You will need to get this from the user. For example, machine name, machine name \ instancename or typically sqlexpress - machine name \ SQLExpress.

http://msdn.microsoft.com/en-us/library/ms165702.aspx

You can also complete the prepaid step and install sqlexpress for your client. There cmdline is installed:

http://msdn.microsoft.com/en-us/library/ms144259.aspx

Another option without sql dependencies is to create your own custom action (command line / API), parse between GO statements in a script, and execute using ADO.net.

Another option outside of installation is the separation of settings and configurations. The installer installs only the bits, and the database is created at runtime through the configuration phase of the product runtime. This has many advantages, including the ability to update your bits (either with a patch or automatically) after the setup phase and before the setup phase. You can also give a better interactive experience and deal with runtime problems - with tuning, your choice is a bad setup and rollback, which is a bad experience.

Hope this helps.

+3
source

Brian has already given you good advice. My recommendation would be for the application itself to be able to deploy the database by running script (s) deployment. You can use a library like dbutilscmd , which parses .sql scripts and executes batches inside the application. I also recommend that your scripts be able to update the database, rather than just deploying it. This will be very convenient when releasing version 2.0 of the application. See Versioning and Database .

Keep in mind that often an initial privilege context is required for an initial database deployment. There are several options; see Learn how to play your applications beautifully with Windows Vista User Account Control .

+2
source

All Articles