将 SQL Server 嵌入到 .NET 应用程序中
嘿,我刚刚写完一个 VB.NET 应用程序。现在我想将可执行文件和数据库打包到一个安装程序文件中。我尝试使用QSetup、InstallShield将SQL Server嵌入到安装文件中,最后经过几个小时的尝试和失败后我毫无头绪。有人吗?
Hey, I've just finished writing a VB.NET application. Now I want to package the executable and the database ofcourse into a single installer file. I tried using QSetup, InstallShield to make SQL Server embedded into the setup file, and finally after hours of try&fail I have no idea. Anyone?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以在 Visual Studio 安装项目的属性上单击鼠标右键,然后出现“先决条件”按钮。您可以在此处勾选“SQL Server Express ...”或“SQL Server Compact 3.5”
链接到图像
您可能最好将连接文件直接设置到 mdf,并在程序运行时附加它。这更容易,因为它不需要自定义安装脚本来将数据库安装到数据库目录本身。
注意:考虑使用紧凑版本,它更小,人们不喜欢计算机上的完整引擎:)
You can do a rightmouse on the properties of your Visual Studio Setup Project, and then there is this button 'Prerequisites'. There you can tick 'SQL Server Express ...' Or the 'SQL Server Compact 3.5'
link to image
You're probably best off just to set the connection file directly to the mdf, and attach it when the program is run. This is easier as it doesn't require a custom setup script to install the database to the database directory itself.
Note: Consider using the Compact Version, it's smaller, people don't like a full blown engine on their computer :)
InstallShield 有一个称为“安装先决条件”的概念,您可以在其中教它如何安装其他软件包以及您自己的软件包。在旧版本中,这会在调用 MSI 之前发生。在较新的版本中,您可以有一个“功能”先决条件,其中先决条件可以与某个功能关联,并且仅在选择要安装该功能并且选择该功能之后但仍在安装执行序列期间发生 MSI 主要活动之前才安装。
InstallShield 还具有针对数据库实例执行 SQL 脚本的模式,以便您可以将数据库加载到新安装的实例中。
所有这些都非常强大,但确实需要一些挖掘才能学习。
InstallShield has a concept called Setup Prerequisites where you can teach it how to install additional packages along with your own. In older versions this would happen before calling your MSI. In newer versions you can have a "Feature" prerequisite where the prereq can associated to a feature and only installed if that feature is selected to be installed and after it's been selected but still before the main activity of your MSI occurs during the install execute sequence.
InstallShield also has a pattern for executing SQL scripts against your database instance so that you can then load your database into your newly installed instance.
All of this is quite powerful but it does take a bit of digging to learn.
据我所知,除了 SQL Server Compact Edition (SQL Server CE) 之外,任何其他版本都不能嵌入到您的设置中,真的。 Microsoft 不希望这样 - 您需要单独安装 SQL Server Express - 任何其他版本甚至不能随您的软件一起提供(客户端必须单独拥有许可证和安装)。
As far as I know, anything but the SQL Server Compact Edition (SQL Server CE) cannot be embedded into your setup, really. Microsoft doesn't want that - you need to have SQL Server Express installed separately - any other edition can't even be shipped with your software (the client must have a license and installation separately).
您确实可以使用自定义应用程序分发 SQL Server:
http: //msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx
You can indeed distribute SQL server with your custom application:
http://msdn.microsoft.com/en-us/library/bb264562(SQL.90).aspx