[英]How to deploy C# windows application (setup file) with database and how to manage connection string on client machine
I am creating C# Windows Application in Visual Studio 2015 . 我正在Visual Studio 2015中创建C# Windows应用程序 。
Question: 题:
How to deploy C# Windows Application (setup file) with SQL Server database with database connection string. 如何使用带有数据库连接字符串的SQL Server数据库部署C#Windows应用程序(安装文件)。
I create common connection string in app.config : 我在app.config中创建公共连接字符串:
<connectionStrings>
<add name="conString"
providerName="System.Data.sqlclient"
connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=
'C:\Users\DEVELOPERS\Documents\Visual Studio 2015\Projects\Provision1\
Provision1\provision1.mdf';Integrated Security=True"/>
</connectionStrings>
Now connection string path location shows my machine. 现在,连接字符串路径位置显示了我的机器。
Then after installation .exe how to connect database and how to manage connection string on client machine. 然后,在安装.exe之后,如何连接数据库以及如何在客户端计算机上管理连接字符串。
The easiest way you can do is: 最简单的方法是:
If you definitive need a setup.exe which installs your software, you can make a new project which is of type setup-programm. 如果您确实需要安装软件的setup.exe,则可以创建一个类型为setup-programm的新项目。 Watch this link for description. 观看此链接以获取描述。
If you don't want your users to see the connectionstring you can use a ConnectionStringBuilder. 如果您不希望用户看到连接字符串,则可以使用ConnectionStringBuilder。 Save just a part of your connection string to app.config and build the rest via Quellcode. 将连接字符串的一部分保存到app.config中,然后通过Quellcode构建其余部分。 Watch this MSDN-Article . 观看此MSDN-Article 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.