当前位置: 动力学知识库 > 问答 > 编程问答 >

winforms - SQL DB Deployment

问题描述:

The scenario:

I have written a software application that includes an installer, that is to be used by Mr Layman to install the system on to a single computer.

The system is a simple C# winforms application with an SQL Express database. The target machine would be a standard installation of Windows XP with SQL Express and .NET 3.5 installed.

I am able to create the installer for the winforms app, that would check the version, create all the directories and copy over all the necessary executable's etc. I have also an SQL script that will create the database and populate it with the necessary data. However I do not know how to go about creating a stand alone installer for the database on the target machine.

I have an SQL script that will create the database etc, but how do I make the installer run this script? I've had a google and I don't really know what I'm looking for, can someone point me in the right direction please.

Thank you in advance.

网友答案:

Create a custom action in the installer project that will take your SQL script and run it against the database. Here's an MSDN link that covers the basics.

网友答案:

An installer which runs SQL scripts can be created in 2 ways:

The very hard way:

  • create an installation with custom dialogs which retrieve the SQL connection information
  • save that information somehow (in an MSI package you can use installer properties)
  • write a custom action which uses that information to connect to SQL Server and run your script

The easy way:

  • use a setup authoring tool which supports SQL scripts

If you want a free solution, I recommend WiX. It has a steep learning curve, but it does what you need.

分享给朋友:
您可能感兴趣的文章:
随机阅读: