日期:2014-05-18  浏览次数:20446 次

帮我看看哪里错了?
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 ";