简体   繁体   English

使用 C# 应用程序安装 SQL Server Express

[英]Install SQL Server Express with C# application

I have an application that needs to have SQL Server installed in order to work, and I need to make an installer for the application that includes the installation of SQL Server Express in case it isn't already installed in the client's computer.我有一个需要安装 SQL Server 才能工作的应用程序,我需要为该应用程序制作一个安装程序,其中包括 SQL Server Express 的安装,以防它尚未安装在客户端的计算机中。

I tried this having my project to have a prerequisite of installing SQL Server 2005 Express Edition SP2 and the option Download prerequisites from the same location as my application , but it doesn't work, as it throws errors such as我试过这个让我的项目有安装SQL Server 2005 Express Edition SP2Download prerequisites from the same location as my application和选项Download prerequisites from the same location as my application ,但它不起作用,因为它会引发错误,例如

Error 43 The install location for prerequisites has not been set to 'component vendor's web site' and the file 'DotNetFX35SP1\\dotNetFX30\\WCS_64.msp' in item '.NET Framework 3.5 SP1' can not be located on disk.错误 43 先决条件的安装位置尚未设置为“组件供应商的网站”,并且无法在磁盘上找到项目“.NET Framework 3.5 SP1”中的文件“DotNetFX35SP1\\dotNetFX30\\WCS_64.msp”。

I have been searching through internet but I could never make any of the methods to work.我一直在通过互联网搜索,但我永远无法使任何方法起作用。

I run into a webpage (the only example I found) to use EnableLaunchApplication.js to have a checkbox to run the program after the installation of itself.我遇到了一个网页(我找到的唯一示例)以使用EnableLaunchApplication.js来设置一个复选框来在安装后运行程序。

But what about an SQL Server Express installation?但是SQL Server Express安装呢?

I am using Visual Studio 2008 with C#.我在 C# 中使用Visual Studio 2008

EDIT:编辑:

In my setup project, I have a PostBuildEvent在我的安装项目中,我有一个 PostBuildEvent

cscript.exe"$(ProjectDir)EnableLaunchApplication.js" "$(BuiltOuputPath)"

but I never got the file EnableLaunchApplication.js (it's not a project I made, but I have to figure out a way to fix this..).但我从来没有得到文件EnableLaunchApplication.js (这不是我做的项目,但我必须想办法解决这个问题..)。

So I finally got to make execute the SQL Server Express installer while installing my app, but now another problem comes up, as apparently it can't have two instances of the windows installer, so I can't install the SQL Server Express. 所以我最终在安装我的应用程序时执行了SQL Server Express安装程序,但现在出现了另一个问题,因为显然它不能有两个Windows安装程序实例,所以我无法安装SQL Server Express。

According to http://msdn.microsoft.com/en-us/library/bb264562%28v=sql.90%29.aspx , maybe the easiest solution would be Install the custom application first. Then install SQL Server Express. 根据http://msdn.microsoft.com/en-us/library/bb264562%28v=sql.90%29.aspx ,也许最简单的解决方案是首先Install the custom application first. Then install SQL Server Express. Install the custom application first. Then install SQL Server Express. , but how can I do that automatically? ,但我该怎么做呢?

Thanks a lot in advance. 非常感谢提前。

I did this in VS2005 and all things go prefect.我在 VS2005 中做到了这一点,一切都很完美。 But I have the same problem as yours.I think you did all correct just some thing.you that "I finally got to make execute the SQL Server Express installer while installing my app" but how?!但我和你有同样的问题。我认为你做了一些正确的事情。你说“我终于在安装我的应用程序时执行了 SQL Server Express 安装程序”但是如何?! Run a msi file?!运行一个msi文件?! Did you check for previous installed SQL server instance engine?您是否检查了以前安装的 SQL Server 实例引擎? Why you want to install your app before SQL server?!为什么要在 SQL Server 之前安装您的应用程序?!

An other question is if client already have SQL server engine it is a good property and prefect and you have not to install it.另一个问题是,如果客户端已经有 SQL 服务器引擎,它是一个很好的属性和级长,您不必安装它。

Create a standard installation process dude.install prerequisites first and if they are be installed the install them and if already installed use them.首先创建标准安装过程 dude.install 先决条件,如果已安装,则安装它们,如果已安装,则使用它们。

And the last.而最后。 Install Windows installer as a prerequisite.安装 Windows 安装程序作为先决条件。

Try to do every thing in its common process.尝试在其共同的过程中做每一件事。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM