我没有分,你们会帮我吗?
<appSettings>
<add key= "ConnStr " value= "provider=microsoft.jet.oedb.4.0;data source= ">
</add>
<add key= "DbPath " value= "Data/login.mdb "> </add>
</appSettings>
namespace test
{
/// <summary>
/// OledbConn 的摘要说明。
/// </summary>
public class OleDbConn
{
public OleDbConn()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public OleDbConnection oledbconn()
{
string connstr=System.Configuration.ConfigurationSettings.AppSettings[ "ConnStr "].ToString()+System.Web.HttpContext.Current.Server.MapPath(System.Configuration.ConfigurationSettings.AppSettings[ "DbPath "].ToString());
return new OleDbConnection(connstr);
}
public OleDbDataReader dr()
{
OleDbConnection conn=this.oledbconn();
conn.Open();
string sql= "select * from admin ";
OleDbCommand cmd=new OleDbCommand(sql,conn);
OleDbDataReader dr=cmd.ExecuteReader(CommandBehavior.CloseConnection);
return dr;
}
}
}
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!this.IsPostBack)
{
OleDbConn oc=new OleDbConn();
this.DataGrid1.DataSource=oc.dr();
this.DataGrid1.DataBind();
}
}
上面是我我的代码,下面是它的错误,为什么它会执行不了,请大家帮忙指点一下。万分感激。
Server Error in '/test ' Application.
--------------------------------------------
No error information available: REGDB_E_CLASSNOTREG(0x80040154).
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:
System.Data.OleDb.OleDbException: No error information available: REGDB_E_CLASSNOTREG(0x80040154).
Source Error:
Line 26: {
Line 27: OleDbConnection conn=this.oledbconn();
Line 28: conn.Open();
Line 29: string sql= "select * from admin ";
Line 30:
Source File: c:\inetpub\wwwroot\test\oledbconn.cs Line: 28
Stack Trace:
[OleDbException (0x80040154): No error information available: REGDB_E_CLASSNOTREG(0x80040154).]
[InvalidOperationException: The 'microsoft.jet.oedb.4.0 ' provider is not registered on the local machine.]
System.Data.OleDb.OleDbConnection.CreateProviderError(Int32 hr)