DropDownList问题
运行时出现错误,如果把where depID='"+this.DropDownList1.SelectedValue+"'这段去掉就能正常运行
{
if(!Page.IsPostBack){
string connstring="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=department.mdb;";
string commstring="select * from TDdepartment";
string commstring1="select * from emp where depID='"+this.DropDownList1.SelectedValue+"'"; OleDbConnection conn=new OleDbConnection(connstring);
OleDbCommand comm=new OleDbCommand(commstring,conn);
comm.Connection.Open();
dr=comm.ExecuteReader();
this.DropDownList1.DataSource=dr;
this.DropDownList1.DataTextField="depName";
this.DropDownList1.DataValueField="depID";
this.DropDownList1.DataBind();
dr.Close();
OleDbCommand comm1=new OleDbCommand(commstring1,conn);
dr1=comm1.ExecuteReader();
while (dr1.Read())
{
this.ListBox1.Items.Add(new ListItem(dr1.GetString(1),dr1.GetInt32(0).ToString()));
}
dr1.Close();
}
}
提示错误如下:
--------------------------------------------------------------------------------
Server Error in '/shuju2' Application.
--------------------------------------------------------------------------------
準則運算式的資料類型不符合。
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: 準則運算式的資料類型不符合。
Source Error:
Line 38: dr.Close();
Line 39: OleDbCommand comm1=new OleDbCommand(commstring1,conn);
Line 40: dr1=comm1.ExecuteReader();
Line 41: while (dr1.Read())
Line 42: {