有什么办法在服务器变动以后不用重新编译程序?

yaqian82 2005-06-15 12:05:53
正为连接数据库配置文件而发愁。 若连接字串在程序里设定的话,服务器一有变动,程序就得重新编译;又不愿意写进INI文件。有没有什么控件、组件可以简单的实现?
...全文
153 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2005-06-15
  • 打赏
  • 举报
回复
is it webform or winform? in both cases, you can put the connection string in the configuration file, see

<configuration>
<appSettings>
<add key="MyDatabaseConnectionString" value="Provider=Microsoft.Jet,..."/>
<add key="MyExcelFileName" value="C:\...\myWorksheet.xls"/>
</appSettings>
</configuration>


From VB.NET you can read this using:

Dim aConfig As Configuration.ConfigurationSettings
Dim aExcelFile As String = aConfig.AppSettings("MyExcelFileName")


In C# you can write:

using System.Configuration;

string aExcelFile;
aExcelFile = ConfigurationSettings.AppSettings.Get("MyExcelFileName");


see
http://www.thescarms.com/dotNet/AppSettings.asp

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧