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)
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)
解决方案 »
- DataTable进行汇总
- vs快捷键突然失效.............................
- 我想問一下我想在后台代碼里寫Repeater.Itemtemplate這個屬性,行嗎?
- 请教大家!
- 怎樣把一個 內碼為unicode的文件轉換為gb2312文件.
- 急!关于javascript的问题!在线等!!!
- 为什么不能连接数据库???
- 我正在学C# 老师要求装vs2005 是不是要完全安装还是只要安装C#的编译器
- 类库项目里能调用log4net写日志吗?
- 在webform中如何动态创建一个*.txt文件,并写入内容???
- 清空窗体?
- [高难度提问] 如何用 C# Webbrowser 取到 QQ城市达人的 QQ 号码
string connStr = "PROVIDER=microsoft.ACE.oledb.12.0;Data Source=" + dbname;
应该是这里出现问题了!debug!
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;
user.DataSource =ds.Table[0];
user.DataBind();
da.Fill(ds, "admin");
user.DataSource =ds.table["admin"];
你这里要把admin写上