当前位置: 代码迷 >> ASP.NET >> 帮小弟我看看错哪了
  详细解决方案

帮小弟我看看错哪了

热度:9016   发布时间:2013-02-25 00:00:00.0
帮我看看哪里错了?
static   string   conStr   =   "Provider=Microsoft.Jet.OLEDB.4.0;Data   Source= "   +Server.MapPath( ". ")   +   "..\\Database\\new.mdb ";
OleDbConnection   olconn=new   OleDbConnection(conStr);
错误:System.Web.UI.Page.Server表示属性,此处应为方法

如何改?

------解决方案--------------------------------------------------------
1。
LS 大侠们,是编译错误,编译都没通过怎么启动调试?

2。
static string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " +Server.MapPath( ". ") + "..\\Database\\new.mdb ";
============
如果这段代码再 .aspx.cs 中,那么你无法这样声明并实例化

Server 作为 Page 的实例属性,你的Page都还没实例化,怎么会能去调用它的属性?

3。

》》》

static string conStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + System.Web.HttpContext.Current.Server.MapPath( ". ") + "..\\Database\\new.mdb ";


  相关解决方案