How do I attach my sql server 2012 database in a C # visual studio 2012 installer?

's Good in itself, is the following, I have an application for membership in c# that handles reports and obviously a Database, my question is the following as I can do so that when the installer of the application install sql server will create automatically the database on the PC where you want to install, I have heard something about scripts in the installer, but I don't understand very well, if I explain something is that I need a specific answer, and specifies, de antemanos thanks for the help.

 1
Author: Julio Martinez, 2016-09-16

2 answers

You can use InstallShield, it is an application that allows you to make installers with database and is also quite intuitive.

If you can't use the Visual Studio Installer, you have to add the file .mdfto the project, and for the connectionstringyou can store it in the app.config or in the usersettings.

To generate the installer you can create a new installation project or go to:

Proyecto -> Propiedades -> Publicar

In the following link you can see a reference video where they do the process above mentioned: Video

 2
Author: Alejandro Ricotti, 2020-06-11 10:54:57

Uses Inno Setup , which unlike the others is free and you can distribute your installer freely, you can create the script (instructions) for the creation of the base, which you can run using a file .bat

 @ECHO OFF
ECHO Creando Base de Datos...
"C:\Program Files (x86)\MyProgram\MySQL\MySQL Server 5.5\bin\mysql.exe" -u root --password=pass -P 6666 < "C:\Program Files (x86)\MyProgram\scripts\create-database.sql"

Basically you run your program (in case it is MySQL), passing the path of the same, then you pass the data of the server -u followed by the user (in this example "root") --password followed by the password (pass) -p followed port (6666) and at the end < followed by the path of the script.sql

Similarly you can create the script and the .bat from the same installer to pass the path selected by the user.

 0
Author: Angel Montes de Oca, 2017-06-01 21:53:05