怎么访问vs2008项目下的app.config文件

nalisaki 2010-05-07 10:52:30
我建了一个winform程序,想访问app.config文件中的connectionstring,但不知道怎么访问,不想直接复制过去,不知道有什么办法没有,记过,好像要通过什么manager吧!!
...全文
153 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Justin-Liu 2010-05-07
  • 打赏
  • 举报
回复
LZ结贴
st200316 2010-05-07
  • 打赏
  • 举报
回复
哈哈 都已经有了 路过
苦苦挣扎中 2010-05-07
  • 打赏
  • 举报
回复
ConfigurationManager.ConnectionStrings["connectionstring"];
呵呵,这个是专门去连接字符串的
捷哥1999 2010-05-07
  • 打赏
  • 举报
回复
用ConfigurationManager类的ConnectionStrings 属性 直接可以得到了。
要引用System.Configuration
gohappy2008 2010-05-07
  • 打赏
  • 举报
回复
private static readonly string path = System.Configuration.ConfigurationManager.AppSettings["connectionstring"];
hsghxm 2010-05-07
  • 打赏
  • 举报
回复
楼上都说了,全对!
lanfengsese 2010-05-07
  • 打赏
  • 举报
回复
       public static string strConnectString = "";
//Manage .Properties .Resources .strConnectString ;
public static SqlConnection myConn;
public Connectbase()
{

try
{
strConnectString =ConfigurationManager.AppSettings["connectstring"].ToString().Trim();

myConn = new SqlConnection(strConnectString);
}
catch (Exception ex)
{
throw ex;
}



}
lovetsfuer 2010-05-07
  • 打赏
  • 举报
回复
private static readonly string path = ConfigurationManager.AppSettings["DAL"].ToString().Trim();

private static readonly string path = ConfigurationManager.AppSettings["DAL"].ToString().Trim();
codeingsky 2010-05-07
  • 打赏
  • 举报
回复
一句话就可以了!
System.Configuration.ConfigurationManager.AppSettings["connectionstring"];

110,535

社区成员

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

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

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