不知道什么问题
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
if(!IsPostBack)Bindgrid();
}
public void Bindgrid()
{
string cnn_str= "Provider=Microsoft.Jet.OleDb.4.0;Data Source= ";
cnn_str+=Server.MapPath( "database/web.mdb ");
OleDbConnection objConnection=new OleDbConnection(cnn_str);
objConnection.Open();//打开连接
string sql_search = "select * from cj_7 where kind = 1 ";
if(txt_ID.Text!= " ")
{
sql_search += "and stu__ID = "+Convert.ToInt64(txt_ID.Text.Trim())+ " ";
}
OleDbDataAdapter da_search = new OleDbDataAdapter(sql_search,objConnection);
DataSet ds_search = new DataSet();
da_search.Fill(ds_search, "ds_name ");
dg_search.DataSource=ds_search;
dg_search.DataBind();
objConnection.Close();
}
错误提示:
“/myweb”应用程序中的服务器错误。
--------------------------------------------
至少一个参数没有被指定值。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。
异常详细信息:
System.Data.OleDb.OleDbException: 至少一个参数没有被指定值。
源错误:
行 43: OleDbDataAdapter da_search = new OleDbDataAdapter(sql_search,objConnection);
行 44: DataSet ds_search = new DataSet();
行 45: da_search.Fill(ds_search, "ds_name ");
行 46: dg_search.DataSource=ds_search;
行 47: dg_search.DataBind();
源文件: c:\inetpub\wwwroot\myweb\stu_search.aspx.cs 行: 45
堆栈跟踪:
[OleDbException (0x80040e10): 至少一个参数没有被指定值。]
System.Data.OleDb.OleDbCommand.ExecuteCommandTextErrorHandling(Int32 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.FillFromCommand(Object data, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 &n