c# - create Database with .net installshield 2015 -


i'm trying create installer file installs database using install shield 2015.

i'm following link walkthrough: using custom action create database @ installation

since link refers older install shield didn't managed make work. have created install file in main windows form application, can see in below code.

public partial class deployinstaller : system.configuration.install.installer {     system.data.sqlclient.sqlconnection masterconnection = new system.data.sqlclient.sqlconnection();     public deployinstaller()     {         initializecomponent();     }       private string getsql(string name)     {          try         {             // gets current assembly.             assembly asm = assembly.getexecutingassembly();              // resources named using qualified name.             stream strm = asm.getmanifestresourcestream(asm.getname().name + "." + name);              // reads contents of embedded file.             streamreader reader = new streamreader(strm);             return reader.readtoend();          }         catch (exception ex)         {             //interaction.msgbox("in getsql: " + ex.message);             throw ex;         }     }      private void executesql(string sql)     {         masterconnection.connectionstring = "data source=.//sqlexpress;initial catalog=master;integrated security=true; multipleactiveresultsets=true; application name=entityframework";          system.data.sqlclient.sqlcommand command = new system.data.sqlclient.sqlcommand(sql, masterconnection);          // initialize connection, open it, , set "master" database         command.connection.open();         try         {             command.executenonquery();         }                 {             // closing connection should done in block             command.connection.close();         }     }      protected void adddbtable()     {         try         {             // creates database.             //executesql("master", "create database " + strdbname);              // creates tables.             executesql( getsql("sql.txt"));          }         catch (exception ex)         {             // reports errors , abort.             //interaction.msgbox("in exception handler: " + ex.message);             throw ex;         }     }       public override void install(system.collections.idictionary statesaver)     {         base.install(statesaver);         adddbtable();     } } 

supposedly piece of code provides user ability of doing both installation of system , corresponding database. reason system being installed. when attempting install database, preventing completing. unfortunately, cannot pinpoint reason why because doesn't give out error reason. never being started or did wrong.

any guide appreciated.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -