简体   繁体   English

如何在客户端上使用 sql server 数据库部署应用程序

[英]How to deploy application with sql server database on clients

I have designed an accounts software for my clients.我为我的客户设计了一个账户软件。 I used SQL Server 2008 database with Stored Procedures.我将 SQL Server 2008 数据库与存储过程一起使用。 It is developed in Visual Studio 2010, .NET Framework 3.0.它是在 Visual Studio 2010、.NET Framework 3.0 中开发的。 I have more than 500 clients using Windows 7.我有 500 多个使用 Windows 7 的客户端。

The major problem is:主要问题是:

Is SQL Server runtime automatically installed with .NET Framework? SQL Server 运行时是否随 .NET Framework 自动安装? As MS Access database does not required Office to be installed on client.由于 MS Access 数据库不需要在客户端上安装 Office。

I can not installed SQL Server 2008 on each client, it is a tough job.我不能在每个客户端上都安装 SQL Server 2008,这是一项艰巨的工作。 Also the clients are not having a good knowledge of installation process.此外,客户对安装过程没有很好的了解。

How to run SQL Server database on clients without installing its setup on clients?如何在客户端上运行 SQL Server 数据库而不在客户端上安装其设置? Is there any runtime files or setup?是否有任何运行时文件或设置?

Option 1 - Setup Project选项 1 - 设置项目

Using Visual Studio you can create a setup project and install prerequisites that you need during installation.使用 Visual Studio,您可以创建安装项目并安装安装过程中所需的先决条件。

The installation process is very simple and the end user can install application and prerequisites after clicking next buttons.安装过程非常简单,最终用户可以在单击下一步按钮后安装应用程序和先决条件。

Here are the steps for Creating a Setup Project:以下是创建安装项目的步骤:

1- Create ac# Windows Forms Application 1- 创建 ac# Windows 窗体应用程序

  1. Create a C# Windows Forms Project创建 C# Windows 窗体项目
  2. Add New Item and Add SQL Server Database to your application添加新项目并将 SQL Server 数据库添加到您的应用程序
  3. Add a table to your application and fill some data in it向您的应用程序添加一个表并在其中填充一些数据
  4. Show the data in your main form.在主窗体中显示数据。

2- Create a Setup Project 2- 创建一个安装项目

  1. Add new project → setup and deployment → setup project添加新项目 → 设置和部署 → 设置项目
  2. Right Click on Setup project and Add project Output and select primary output from your main project右键单击 Setup project 和 Add project Output 并从主项目中选择主要输出
  3. Right Click on Setup project and Add project Output and select content files from your main project右键单击 Setup project 和 Add project Output 并从主项目中选择内容文件
  4. Right CLick on setup project and Click Properties and click Prerequisites and select SQL Server Express右键单击安装项目并单击属性并单击先决条件并选择 SQL Server Express
  5. Select .Net Framework选择 .Net 框架
  6. Select Windows Installer选择 Windows 安装程序
  7. Select radio button Download prerequisites from the same location as my application.选择单选按钮从与我的应用程序相同的位置下载先决条件。
  8. Right Click on Users Desktop at left pane and add new Shortcut and select application folder, primary output from SampleApplication, and click ok and the rename the short cut to what you need.右键单击左窗格中的用户桌面并添加新快捷方式并选择应用程序文件夹、SampleApplication 的主要输出,然后单击确定并将快捷方式重命名为您需要的名称。
  9. Rebuild solution.重建解决方案。
  10. Rebuild Setup Project重建安装项目
  11. Go to Output directory of setup project and run setup.exe转到安装项目的输出目录并运行 setup.exe

It's that easy.就这么简单。

For more information take a look at following docs articles:有关更多信息,请查看以下文档文章:

  1. How to: Create or Add a Setup Project 如何:创建或添加安装项目
  2. How to: Install Prerequisites in Windows Installer Deployment 如何:在 Windows Installer 部署中安装先决条件
  3. Walkthrough: Using a Custom Action to Create a Database at Installation 演练:在安装时使用自定义操作创建数据库

Option 2 - ClickOnce选项 2 - ClickOnce

Using Visual Studio another option is using ClickOnce publishing.使用 Visual Studio 的另一个选择是使用 ClickOnce 发布。

To do so, in properties of your project, in publish tab, click prerequisites button, you can select SQL Express in prerequisites.为此,在您的项目属性中,在发布选项卡中,单击先决条件按钮,您可以在先决条件中选择 SQL Express。 This way, you only need to set your database files to copy in output directory, and use AttachDbFileName in connection string: Data Source=.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\Database.mdf; Initial Catalog=Master"这样,您只需要将您的数据库文件设置为复制到输出目录中,并在连接字符串中使用 AttachDbFileName: Data Source=.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\Database.mdf; Initial Catalog=Master" Data Source=.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\Database.mdf; Initial Catalog=Master" Data Source=.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\Database.mdf; Initial Catalog=Master" . Data Source=.\\SQLEXPRESS; AttachDbFilename=|DataDirectory|\\Database.mdf; Initial Catalog=Master"
For more information take a look at the following docs article:有关更多信息,请查看以下文档文章:

LocalDB is Microsoft's current recommended solution. LocalDB是 Microsoft 当前推荐的解决方案。 It allows you to connect to a database file directly, without having to install an instance of the Full SQL Server, or SqlExpress.它允许您直接连接到数据库文件,而无需安装完整 SQL Server 或 SqlExpress 的实例。 It is fully compatible with the full version of SQL server.它与完整版的 SQL Server 完全兼容。 There are no installation requirements on the client end, as the libraries are packages along with your application when it is built.客户端没有安装要求,因为库在构建时与您的应用程序一起打包。

You can read more about it here .您可以在此处阅读更多相关信息。

您可以通过这种方式在您的设置中以静默安装方式安装 sql express 不显示任何安装 sql express 的向导 阅读此链接

I have followed your solution and I have tried LocalDB as well, but I am getting an exception, any idea? 我已经按照您的解决方案进行了尝试,也尝试了LocalDB,但是我遇到了例外,您知道吗?

这是我正在使用的设置

这是我得到的例外

暂无
暂无

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

相关问题 如何使用SQL Server数据库部署C#/ WPF应用程序 - How To Deploy C#/WPF Application With SQL Server Database 如何使用MS SQL Server数据库发布和部署Asp.net核心数据库优先应用程序 - How to publish and deploy an Asp.net Core Database first application with MS SQL Server Database 如何部署“SQL Server Express + EF”应用程序 - How to Deploy “SQL Server Express + EF” Application 如何使用SQL Server数据库部署Windows应用程序? - How to deploy Windows app with SQL Server database? 具有集中式数据库服务器和数据库(SQL Server 2008)的多个客户端(WPF应用程序) - Multiple Clients (WPF Application) with centralized Database server and Database (SQL server 2008) 无法使用SQL Server CE database.file部署应用程序 - Cannot deploy application with SQL Server CE database.file 如何在Visual Studio 2010中使用SQL Server 2012数据库打包和部署C#桌面应用程序? - How to package and deploy a C# desktop application with a SQL Server 2012 database in Visual Studio 2010? 如何在应用程序设置中部署Sql Server数据库? - How can I deploy a Sql Server database as part of an application's setup? 如何使用Winform Application部署和附加SQL Server Management Studio 2012数据库? - How to deploy and attach SQL Server Management Studio 2012 Database with Winform Application? 如何部署SQL函数以定位SQL Server 2016数据库 - How to deploy SQL Function to target SQL Server 2016 database
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM