当前位置: 代码迷 >> ASP.NET >> 请问下在web.config里发布网站后的Data Soure的有关问题,多谢大家帮助
  详细解决方案

请问下在web.config里发布网站后的Data Soure的有关问题,多谢大家帮助

热度:8504   发布时间:2013-02-25 00:00:00.0
请教下在web.config里发布网站后的Data Soure的问题,谢谢大家帮助
我在web.config里写了连接串 <add   key= "ConnectionString "   value= "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source=App_Data/DataBase.mdb;   User   Id=admin;Password= "/> ,在VS2005的开发环境下使用时候没有问题,可用vs2005进行 "生成 "→ "发布网站 "发布到本机后,连接串里的Data   Source= "这里竟然变成了本机的IP地址 ",由于我使用的是Access库不是Sql   server库,直接用本机IP是不能连数据库的,而&Server.MapPath()这种写法又只能在Web页里用,我想请教下在web.config应该怎么写这种连接串啊?

谢谢大家帮忙!

------解决方案--------------------------------------------------------
system.Configuration.ConfigurationManager.ConnectionStrings( "YuanXinConnectionString ").ConnectionString
------解决方案--------------------------------------------------------
</configSections>
<connectionStrings>
<add name= "ConnectionString " connectionString= "连结字符串 " />
</connectionStrings>
使用
private static string strConn = System.Configuration.ConfigurationManager.ConnectionStrings[ "ConnectionString "].ConnectionString;
  相关解决方案