我是做个登录页面的,ACCESS做数据库,为了让数据库能够复用,做了个CS类来连接ACCESS代码如下:public class loginuser
{
public loginuser()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
public static OleDbConnection CreateConnection()
{
String strConnection="Provider=Micrsoft.Jet.OleDb.4.0;Data Source=E:\\Inetpub\\wwwroot\\business\\loginManage.mdb;";
OleDbConnection objConnection=new OleDbConnection(strConnection);
return objConnection;
}
}然后是在主页面上来进行查询代码如下:private void Button1_Click(object sender, System.EventArgs e)
{
string account=Request.Form.Get("loginid").ToString();
string password=Request.Form["loginpass"].ToString(); OleDbConnection objectConnection=loginuser.CreateConnection();
objectConnection.Open();
OleDbCommand cmd=new OleDbCommand("select count(*) from win where account='"+loginid+"' and password='"+loginpass+"'");
int count=Convert.ToInt32(cmd.ExecuteScalar());
if (count>0)
{
Response.Redirect("main.html");
}
else
{
Response.Redirect("loginfail.html"); }
}执行后提示错误"System.Data.OleDb.OleDbException: 没有可用的错误信息: REGDB_E_CLASSNOTREG(0x80040154)。"源错误: (行58)
行 56: 
行 57:  OleDbConnection objectConnection=loginuser.CreateConnection();
行 58:  objectConnection.Open();
行 59:  OleDbCommand cmd=new OleDbCommand("select count(*) from win where account='"+loginid+"' and password='"+loginpass+"'");
行 60:  int count=Convert.ToInt32(cmd.ExecuteScalar());
 
堆栈跟踪: 
[OleDbException (0x80040154): 没有可用的错误信息: REGDB_E_CLASSNOTREG(0x80040154)。][InvalidOperationException: 未在本地计算机上注册“Micrsoft.Jet.OleDb.4.0”提供程序。]
   System.Data.OleDb.OleDbConnection.CreateProviderError(Int32 hr)
   System.Data.OleDb.OleDbConnection.CreateProvider(OleDbConnectionString constr)
   System.Data.OleDb.OleDbConnection.Open()
   business.WebForm1.Button1_Click(Object sender, EventArgs e) in e:\inetpub\wwwroot\business\webform1.aspx.cs:58
   System.Web.UI.WebControls.Button.OnClick(EventArgs e)
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
   System.Web.UI.Page.ProcessRequestMain()不知道是啥毛病