使用ClickOnce部署数据库和应用程序 [英] deploying a database and application with ClickOnce

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

问题描述

我是ClickOnce的新手。我使用C#和SQL Server Express创建了WinForms应用程序。目前,我的数据库位于mssql数据文件夹中。我的连接字符串位于app.config文件中。

I am new to ClickOnce. I created a WinForms application using C# and SQL Server Express. Currently my database is located in the mssql data folder. My connection string is located in an app.config file.

<add name="default"  providerName="System.Data.SqlClient"
  connectionString="Server=localhost\SQLEXPRESS;Database=DBase;Trusted_Connection=True;" />




  • 如何包含我的数据库文件以进行部署

    • How do I include my database file for it to deploy with the application?

      将数据库部署到哪个文件夹,并且我的连接字符串(上面)仍将正常工作?

      To which folder will the database be deployed and will my connection string (above) be still working?

      推荐答案

      您有两个选择。首先,如果这是一个简单的数据库,我建议您放弃使用SQL Express并使用SQL Server Compact。 Compact SQL数据库是可以与应用程序安装捆绑在一起的文件。下面是一个链接,指导您完成SQL Compact数据库的创建过程。

      You have a couple of options. First, if this is a simple database I recommend that you forego using SQL Express and use SQL Server Compact. A Compact SQL database is a file that can be bundled with your application installation. Below is a link guiding you through the creation process of a SQL Compact database.

      http://technet.microsoft.com/zh-cn/library/ms173009.aspx

      以下链接讨论了设置SQL Server Compact的必要依赖关系和先决条件。 (请注意,您需要滚动到标题为基于私有文件的部署的部分。)

      The following link discusses setting up the necessary dependencies and prerequisites for SQL Server Compact. (Note, you will need to scroll to the section entitled Private File–Based Deployment.)

      http://msdn.microsoft.com/en-us/library/aa983326(v=VS.100).aspx

      如果您有一个复杂的数据库,或者一个数据库的大小可能超过为SQL Compact数据库设置的3GB限制,则唯一的选择是设置将SQL Server Express作为应用程序的先决条件,安装后,在应用程序中创建一个例程,以检查SQL Express中是否存在数据库,如果不存在,则启动数据库创建和更新例程。

      If you have a complex database, or one that may grow larger than the 3GB limit that is set for SQL Compact databases, the only alternative is to set SQL Server Express as a prerequisite to your application and once it is installed create a routine within your application that checks to see if your database exists in SQL Express and, if not, launches a database creation and updating routine.

      对于我来说,我有一个笨重的,数据驱动的应用程序,该应用程序是在SQL Compact推出之前编写的,必须在经常与服务器断开连接的环境中运行。我必须使用SQL Express,以便我们必须开发一种机制来在服务器可用时检查数据库更新。如果有更新,则会根据子数据库顺序下载并执行加密的脚本文件。更新数据库容器后,将调用后续例程以检查和同步数据。

      In my case, I have a heavy, data-driven application that was written before SQL Compact was out and had to function in environments that were often disconnected from our servers. I had to use SQL Express so that we had to develop a mechanism to check for database updates when the server was available. If there are updates, encrypted script files are downloaded and executed, sequentially against the child database. After the database container is updated, a follow-up routine is called to check and synchronize the data.

      -编辑-

      我想快速回答一下,是的,您可以将SQL Server数据库以编程方式捆绑和附加到SQL Server的本地实例。这样做有很多障碍,如果您的用户群使用Windows的多个版本,PC体系结构和多种不同的安全方案,则可能难以始终如一地将数据库附加到用户的SQL Server。是的,可以做到。但是,我建议不惜一切代价避免这种情况。

      I wanted to quickly respond that, yes, you can bundle and attach a SQL Server database programatically to a local instance of SQL Server. There are many barriers to this and if you have a user base that uses multiple versions of Windows, PC architectures and multiple different security scenarios, you will probably have trouble consistently attaching your database to the user's SQL Server. Yes, it can be done. However, I'd recommend avoiding that scenario at all possibly costs.

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

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