How do I attach my sql server 2012 database to a c # visual studio 2012 installer?

1

Good in itself is the following, I have a membership application 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 is created automatically the database on the PC where you want to install, I heard something about scripts in the installer but I do not understand very well if they explain something to me I need a specific and specific answer, in advance thanks for the help.

    
asked by Julio Martinez 16.09.2016 в 02:55
source

2 answers

2

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

If you can not use the Visual Studio installer, you have to add the .mdf file to the project, and for the connectionstring you can store it in app.config or in usersettings .

To be able 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 aforementioned process: Video

    
answered by 16.09.2016 в 15:54
0

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

 @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 execute your program (in case it is MySQL), passing the route of it, followed by the server data -u followed by the user (in this example "root") --password followed by the password (pass) -p followed by port (6666) and at the end < followed by the path of script.sql

In the same way you can create the script and the .bat from the same installer to pass the route selected by the user.

    
answered by 01.06.2017 в 23:53