Re: How to setup database in VS Setup project?



"Brandon" <Brandon@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:1758B71A-3AF5-4D76-81BB-0A83E82F5790@xxxxxxxxxxxxxxxx
I have a .sql script that holds the configuration of a local sql express
database needed for my C# .net forms app. I would like the script to run.
Right now, I have a install_db.cmd file that basically just runs the sql
script from the command line. I made a console app that runs the
install_db.cmd

I added that console app to the application folder and then ran that as a
custom action. The command windows pops up real quick, but then goes away
and
the database never actually gets created.

Any ideas how to do this better or make it actually work?

You can use something like this:

using (SqlConnection connection = new
SqlConnection(connectionString))

{

using (SqlCommand command = new SqlCommand())

{

command.Connection = connection;

command.CommandText = File.ReadAllText("file.sql");

connection.Open();

command.ExecuteNonQuery();

}

}



The difference is that you need to execute one batch at a time. You can't
execute the whole thing at once. I have used a regular expression and the
..Split method to split the file on the "GO" commands, then execute each
batch one at a time.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer


.



Relevant Pages

  • CGIscript.net - csMailto.cgi - Remote Command Execution
    ... CGIscript.net - csMailto.cgi - Remote Command ... csMailto is a perl cgi formmail script developed by ... execute command on server and mail output to anyone ...
    (Bugtraq)
  • Re: shell scripting
    ... and am assuming an sh-compatible shell here.... ... command 1 options arguments ... To run the script, do: ... then you need to use the full path to execute it: ...
    (comp.unix.questions)
  • Re: shell scripting
    ... and am assuming an sh-compatible shell here.... ... command 1 options arguments ... To run the script, do: ... then you need to use the full path to execute it: ...
    (comp.unix.shell)
  • =?iso-8859-1?Q?Re:_Jcl?=
    ... I can send you a program that you execute as a step in your job and it ... I have a command and job scheduler that is available in a free version ... demand script processor with the full scripting ability so that your job ...
    (bit.listserv.ibm-main)
  • Re: sms installer- automate installing local printer
    ... Thanks Terry- Here is the script that I used that seemed to work- I just had ... > However since you are asking about getting the command line to work we can ... execute program this is where you are making the most mistakes. ...
    (microsoft.public.sms.installer)