using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;using System.Data.OleDb;public partial class Admin_user : System.Web.UI.Page
{
   protected void Page_Load(object sender, EventArgs e)
    {
        string dbname = System.Web.HttpContext.Current.Server.MapPath("../App_Data/bden.mdb");
        string connStr = "PROVIDER=microsoft.ACE.oledb.12.0;Data Source=" + dbname;
        OleDbConnection conn = new OleDbConnection(connStr);
        conn.Open();
        string strSql = "select * from admin order by id desc";
        OleDbCommand cmd = new OleDbCommand();
        cmd.Connection = conn;
        cmd.CommandText = strSql;
        OleDbDataAdapter da = new OleDbDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds, "admin");
        user.DataSource =ds;
        user.DataBind();
    }
}
出错用红色标记标注,下面是出错信息
用户代码未处理 System.Data.OleDb.OleDbException
  Message="至少一个参数没有被指定值。"
  Source="Microsoft Office Access Database Engine"
  ErrorCode=-2147217904
  StackTrace:
       在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(OleDbHResult hr)
       在 System.Data.OleDb.OleDbCommand.ExecuteCommandTextForSingleResult(tagDBPARAMS dbParams, Object& executeResult)
       在 System.Data.OleDb.OleDbCommand.ExecuteCommandText(Object& executeResult)
       在 System.Data.OleDb.OleDbCommand.ExecuteCommand(CommandBehavior behavior, Object& executeResult)
       在 System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method)
       在 System.Data.OleDb.OleDbCommand.ExecuteReader(CommandBehavior behavior)
       在 System.Data.OleDb.OleDbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
       在 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
       在 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable)
       在 Admin_user.Page_Load(Object sender, EventArgs e) 位置 e:\ht\Admin\user.aspx.cs:行号 28
       在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
       在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
       在 System.Web.UI.Control.OnLoad(EventArgs e)
       在 System.Web.UI.Control.LoadRecursive()
       在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

解决方案 »

  1.   

    string dbname = System.Web.HttpContext.Current.Server.MapPath("../App_Data/bden.mdb");
      string connStr = "PROVIDER=microsoft.ACE.oledb.12.0;Data Source=" + dbname;
    应该是这里出现问题了!debug!
      

  2.   

    是不是 admin 是关键字 [admin] 试试
      

  3.   

    "select * from [admin] order by [id] desc";
      

  4.   

    string strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;";
                strConnection += @"Data Source=C:\A\Database1.accdb;";
                strConnection += "Persist Security Info=False";
                using (OleDbConnection objConnection = new OleDbConnection(strConnection))
                {
                    objConnection.Open();
                    OleDbDataAdapter myCommandd = new OleDbDataAdapter("select * from Tb", objConnection);
                    DataSet ds = new DataSet();
                    myCommandd.Fill(ds, "test");
                    objConnection.Close();
                }
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\myAccess2007file.accdb;Persist Security Info=False; 
      

  5.   

    select * from [admin] order by id desc
      

  6.   

    按出错信息,应该是admin表不存在,或id列不存在admin并不是关键字
      

  7.   

    da.Fill(ds);
      user.DataSource =ds.Table[0];
      user.DataBind();
      

  8.   

    DataSet ds = new DataSet();
    da.Fill(ds, "admin");
      user.DataSource =ds.table["admin"];
    你这里要把admin写上 
      

  9.   

    问下楼主,你的链接字符用的是microsoft.ACE.oledb.12.0,这个应该是 2007的,但是数据库为啥是bden.mdb,后缀名是mdb,而不是accdb?