用于VB.NET应用程序的SQL数据库部署 [英] SQL database deployment for VB.NET app

查看:133
本文介绍了用于VB.NET应用程序的SQL数据库部署的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里阅读了很多文章,但还没有找到解决方案。我有一个由我的VB.NET应用程序使用的SQL Server Express数据库。我已经通过MSI文件打包和部署应用程序,一切都很好,除了我不知道如何包括我的数据库文件与包。我知道有三种一般的方法来执行此操作(通过手动复制文件,自定义操作和SQL脚本)。我在这里并不需要任何东西,只是将数据库放在客户机上的一个快速方法,这样我的应用程序就可以访问它。

I have read many articles here, but haven't quite found the solution. I have a SQL Server Express database that is used by my VB.NET application. I have packaged and deployed the application via an MSI file and everything works great except I cannot figure out how to include my database file with the package. I understand there are three general ways to do this (copy the files over manually, custom actions, and SQL scripts). I didn't need anything fancy here, just a quick way to put the DB on the client machine so my app can access it.

我决定手动复制DB是最快的选择。我尝试将其放在客户端的SQL Server Express安装的工作目录和 \DATA 目录中,但我的应用程序将无法连接。我也尝试将项目中的连接更改为 .\SQLEXPRESS 而不是 [my_computer_name] \SQLEXPRESS 重建部署项目并重新安装在客户端机器上,但对我来说没有汤。同样的问题。我尝试将项目中的UserInstance属性更改为True,但我的项目不会让我保存该操作。

I decided copying over the DB manually was the quickest option. I tried putting it in the working directory and in the \DATA directory of the client's SQL Server Express install, but my app wouldn't connect. I also tried changing my connection in the project to .\SQLEXPRESS instead of [my_computer_name]\SQLEXPRESS followed by a rebuild of the deployment project and reinstall on the client machine, but no soup for me. Same issue. I tried changing the "UserInstance" property in the project to "True" but my project would not let me save that action.

我正确的是,手动副本是

Am I correct that a manual copy is the quickest and easiest way to get this done?

推荐答案

您应该附加您的文件到Sql Server实例。

You should to attach your file to the Sql Server instance.

CREATE DATABASE YourDatabaseName 
    ON (FILENAME = 'C:\your\data\directory\your_file.mdf'), 
    (FILENAME = 'C:\your\data\directory\your_file_Log.ldf') 
FOR ATTACH; 

这篇关于用于VB.NET应用程序的SQL数据库部署的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆