首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

帮小弟我看看错哪了

2012-02-23 
帮我看看哪里错了?staticstringconStrProviderMicrosoft.Jet.OLEDB.4.0DataSource +Server.MapPath(

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


热点排行