asp.net遇到的问题,,,求助
编译器错误消息: CS1502: 与“System.Data.Common.DataAdapter.Fill(System.Data.DataTable, System.Data.IDataReader)”最匹配的重载方法具有一些无效参数
源错误:
行 49: con.Open();
行 50: com = new System.Data.OleDb.OleDbCommand(strSql, con);
行 51: System.Data.Common.DataAdapter.Fill(myds, ddl.SelectedItem.Text);
行 52: this.DataGrid1.DataSource = myds.Tables[ddl.SelectedItem.Text].DefaultView;
行 53: this.DataGrid1.DataBind();
源文件: e:\Archive\WebSite1\teacher2.aspx.cs 行: 51
public partial class teacher2 : System.Web.UI.Page
{
protected System.Data.OleDb.OleDbCommand com;
protected System.Data.OleDb.OleDbDataReader reader;
protected System.Data.OleDb.OleDbConnection con;
protected System.Data.OleDb.OleDbDataAdapter da;
protected System.Data.DataSet ds;
protected void Page_Load(object sender, EventArgs e)
{
string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("st.mdb") + ";User Id=admin;Password=;";
con = new OleDbConnection(strcon);
string id, strSql;
id = Session["admin"].ToString();
if (!IsPostBack)
{
strSql = "select xx from [class] where Tnumber='" + id + "'";
con.Open();
com = new System.Data.OleDb.OleDbCommand(strSql, con);
reader = com.ExecuteReader();
while (reader.Read())
{
ddl.Items.Add(reader.GetString(0));
}
reader.Close();
com.Dispose();
con.Close();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DataSet myds = new DataSet();
string strcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("st.mdb") + ";User Id=admin;Password=;";
con = new OleDbConnection(strcon);
string strSql;
string sqlstr = "select sID,sName from "+ddl.SelectedItem.Text;
con.Open();
com = new System.Data.OleDb.OleDbCommand(strSql, con);
System.Data.Common.DataAdapter.Fill(myds, ddl.SelectedItem.Text);
this.DataGrid1.DataSource = myds.Tables[ddl.SelectedItem.Text].DefaultView;
this.DataGrid1.DataBind();
con.Close();
}
不知道该怎么改。。。问题出在DropDownList1这串代码里,我从上一界面进入这一页面的所以 Session["admin"]是有值的,问题出在DropDownList1这串代码里,这串代码里可能还有错能帮我改下吗谢谢
我本意是从DropDownList中选择课程,然后我的课程的表名(里面存储了这课的学生的名字和学号)就是DropDownList中的选项,然后选择了哪个表,我的DataGrid1中就显示出这个课程的学生的学号和名字