简体   繁体   English

使用SQL Server数据库发布应用程序时的主要注意事项

[英]main considerations while publishing application using SQL server Database

I want to ask about the main considerations we have to put in mind when publishing application using SQLServer database? 我想问一下使用SQLServer数据库发布应用程序时我们必须考虑的主要注意事项?

I ask this question because I faced a problem when I developed an application using SQL server Database in C# and used it in another machine. 我问这个问题是因为当我在C#中使用SQL Server数据库开发应用程序并在另一台计算机上使用它时遇到了问题。 The problem is an exception happen in launching the application. 问题是启动应用程序时发生异常。

This is the exception message: 这是异常消息:

<b>"The ConnectionString proberty has not been initialized"</b>. The ConnectionString is in App.config and assing while form loading.

This is the ConnectionString: 这是ConnectionString:

<b>"Data Source=.\SQLEXPRESS;Initial Catalog=test;Integrated Security=True;Pooling=False"</b> and it is in this file: appName.exe.config

The application is Desktop application and it's not need for installation just click .exe and it should connect to the existing SQLServer database with the ConncetionString in the appName.exe.config file. 该应用程序是桌面应用程序,不需要安装,只需单击.exe,它就应该使用appName.exe.config文件中的ConncetionString连接到现有的SQLServer数据库。

The best way to deploy any type of application will be creating a setup.exe or .msi file. 部署任何类型的应用程序的最佳方法是创建setup.exe或.msi文件。 Since this will ensure the important files which will copy to the target machine. 因为这样可以确保将重要文件复制到目标计算机。 It also provides a well structured file hierarchy along custom action which we can program each and every steps of installation. 它还提供了结构良好的文件层次结构以及自定义操作,我们可以对安装的每个步骤进行编程。

It is always good to keep the connection properties in a config file, which helps to change the configuration settings without building the project. 将连接属性保留在配置文件中总是很好的,这有助于在不构建项目的情况下更改配置设置。 The exe will reads data from the config file, so if we changed the values then also it will works fine. 该exe将从配置文件中读取数据,因此,如果我们更改了值,那么它也可以正常工作。 While creating the setup project add the configuration settings and deploy or it is also good to have a common setup msi and different config files. 在创建安装项目时,请添加配置设置并进行部署,或者最好使用通用的安装msi和不同的配置文件。

For example the database may be different for servers like DEV,QA,Staging etc. For each sever the msi will be same but the connection string will be different. 例如,对于DEV,QA,Staging等服务器,数据库可能不同。对于每个服务器,msi都是相同的,但是连接字符串将不同。 So there is also a way to create self extracting files which will update the config files . 因此,还有一种创建自解压文件的方法,该文件将更新配置文件。 For QA,DEV,Staging etc different self extracting files will be there. 对于QA,DEV,暂存等,不同的自解压文件将在那里。 by running those files, it is possible to update the server details and authentication details. 通过运行这些文件,可以更新服务器详细信息和身份验证详细信息。 By providing msi and extracting files, users can install the application very easily 通过提供msi和提取文件,用户可以非常轻松地安装应用程序

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

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