简体   繁体   English

如何使用数据库部署C#Windows应用程序(安装文件)以及如何在客户端计算机上管理连接字符串

[英]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: 最简单的方法是:

  1. Save your connection string in app.config is absolutly common 将连接字符串保存在app.config中是非常常见的
  2. Compile your Project with Release settings 使用发布设置编译项目
  3. Take your .exe file from /bin/release/.. Folder 从/ bin / release / ..中获取您的.exe文件
  4. The Database should be connected via the connection string. 数据库应通过连接字符串连接。 If the database is not connected via network you need to deploy it as well. 如果数据库未通过网络连接,则也需要对其进行部署。
  5. Make sure your clients have .Net Framework installed 确保您的客户端已安装.Net Framework

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.

相关问题 如何在连接字符串中添加数据目录以在客户端计算机上部署应用程序? - How to add data directory in connection string to deploy application on client machine? 使用localdb部署c#Windows应用程序并将其安装在客户端计算机上 - deploy c# windows application with localdb and install it on client machine 关于如何在客户端机器上部署带有中央数据库的窗体应用程序的问题 - Question regarding how to deploy windows form application with central database on client machine 如何在C#Windows应用程序中为整个应用程序设置连接字符串? - How to set connection string for whole application in c# windows Application? 如何通过数据库连接到其他计算机来部署Windows窗体项目? - How to deploy a Windows forms project with a database connection to some other machine? 如何使用C#在Windows应用程序中创建单个文件设置? - How to create single file setup in windows application in c#? 如何在C#Windows应用程序中的一个位置写入数据库连接字符串 - How to write database connection string in one location in C# windows application SharpDevelop C#Windows应用程序已准备好部署..如何将sql数据库移动到客户端PC? 我还需要什么? - SharpDevelop C# Windows Application is ready to deploy .. how to move sql database to client pc? what else i need? 如何在客户端机器上使用 SQL 服务器数据库部署 WinForms 应用程序 - How to deploy WinForms application with SQL Server database on client machine 如何将包含.mdf数据库的C#项目部署到客户端计算机 - How to deploy C# project containing .mdf database to client's machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM