发布项目后如何读取连接字符串? [英] How to read connection string after publishing the project?

查看:69
本文介绍了发布项目后如何读取连接字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个基于桌面的应用程序,发布此项目后,我想更改连接字符串,但是发布项目后,我无法更改连接字符串.如何解决此问题?我也尝试将连接字符串放入app.config,但是发布后未显示app.config.

i have developed a Desktop base application ,after publish this project i want to change connection string but after publishing project i have no way to change connection string.How can i solve this issue?i also try to put my connection string in app.config but after publishing app.config is not shown .

推荐答案

有很多方法可以修改连接字符串.

0)将整个字符串保存在您的应用程序配置中.

1)将属性值保存在应用程序配置中,并根据这些值在应用程序中构造实际字符串

2)如果找不到连接字符串,或者尝试连接时遇到问题,请提示用户输入适当的属性值(服务器,初始目录,用户ID,密码等),然后保存新的应用程序配置中的数据.

您是否使用Settings类将连接字符串存储在app.config中?
There are many ways to modify the connection string.

0) Save the entire string in your app config.

1) Save the attribute values in the app config, and construct the actual string in the application based on those values

2) If the connection string isn''t found, or if there''s a problem encountered when trying to connect, prompt the user for the appropriate attribute values (server, initial catalog, userID, password, etc) and then save the new data in the app config.

Are you using the Settings class to store the connectionstring in the app.config?


这篇关于发布项目后如何读取连接字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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