问题描述
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Data.OleDb;usingSystem.Data;publicpartialclassdl:System.Web.UI.Page{OleDbDataAdapterTables;protectedvoidPage_Load(objectsender,EventArgse){OleDbConnectionmycon=newOleDbConnection();OleDbCommandmycomm=newOleDbCommand();DataSetmyds=newDataSet();}//protectedvoidPage_Load(objectsender,EventArgse)//{//}//Button1.Text="确定";////Button2.Text="取消";//if(IsPostBack!=true)//{//string[]zy=newstring[2]{"管理员","学生"};//DropDownList1.DataSource=zy;//DropDownList1.DataBind();//}//}////protectedvoidButton1_Click(objectsender,EventArgse)////{////}//}//protectedvoidButton1_Click(objectsender,EventArgse)//{//OleDbConnectionmyconn=newOleDbConnection();//stringconstr="Provider=Microsoft.Jet.OLEDB.4.0;datasource="+Server.MapPath("data.mdb");//myconn.ConnectionString=constr;//myconn.Open();//OleDbCommandmycomm=newOleDbCommand();//mycomm.Connection=myconn;//if(DropDownList1.Items[0].Selected)//{//mycomm.CommandText="select*fromglywhere用户名='"+TextBox1.Text+"'and密码='"+TextBox2.Text+"'";//OleDbDataReadermyr;//myr=mycomm.ExecuteReader();//if(myr.Read())//{//Session["用户名"]=myr["用户名"];//Session["密码"]=myr["密码"];//Response.Redirect("chaxun1.aspx");//}}//else//{//Response.Write("<script>alert('登陆失败!');</script>");//}//}//if(DropDownList1.Items[1].Selected)//{//mycomm.CommandText="select*fromt_bmwhere姓名='"+TextBox1.Text+"'and密码='"+TextBox2.Text+"'";//OleDbDataReadermyr;//myr=mycomm.ExecuteReader();//if(myr.Read())//{//Session["姓名"]=myr["姓名"];//Session["密码"]=myr["密码"];//Response.Redirect("chaxun2.aspx");//}//else//{//Response.Write("<script>alert('登陆失败!');</script>");//}//}//}protectedvoidButton1_Click(objectsender,EventArgse)protectedvoidButton1_Click(objectsender,EventArgse){OleDbConnectionmyconn=newOleDbConnection();stringconstr="Provider=Microsoft.Jet.OLEDB.4.0;datasource="+Server.MapPath("data.mdb");myconn.ConnectionString=constr;myconn.Open();OleDbCommandmycomm=newOleDbCommand();mycomm.Connection=myconn;mycomm.CommandText="select*fromzhwherebmh='"+dlm.Text+"'andpwd='"+mm.Text+"'";OleDbDataReadermyr;myr=mycomm.ExecuteReader();if(myr.Read()){stringstr2="selectlx1fromglywherebmh='"+dlm.Text+"'",lx1;myad=newOleDbDataAdapter(str2,constr);myad.Fill(myds,"t_bm");lx1=myds.Tables["t_bm"].Rows[0][0].ToString();Session["bmh"]=myr["bmh"];Session["lx1"]=lx1;if(lx1=="1"){Response.Write("<script>alert('登陆成功!');</script>");Response.Write("<script>document.location='xscj.aspx';</script>");}if(lx1=="2"){Response.Write("<script>alert('登陆成功!');</script>");Response.Write("<script>document.location='gly.aspx';</script>");}//if(lx1=="3")//{//Response.Write("<script>alert('登陆成功!');</script>");//Response.Write("<script>document.location='chaxun3.aspx';</script>");//}}else{Response.Write("<script>alert('登陆失败!报名号或者密码不正确!');window.history.back();</script>");}}publicOleDbDataAdaptermyad{get;set;}publicDataTablemyds{get;set;}}这个是全部的代码,运行的时候提示错误“System.Data.DataTable”不包含“Tables”的定义,并且找不到可接受类型为“System.Data.DataTable”的第一个参数的扩展方法“Tables”(是否缺少using指令或程序集引用?)I:老师原件ACCSS-副本dl.aspx.cs11020I:老师原件ACCSS-副本怎么解决呢
解决方案
解决方案二:
myad.Fill(myds,"t_bm");这里有t_bm表不?你可以myad.Fill(myds);x1=myds.Tables[0].Rows[0][0].ToString();
解决方案三:
DataTablemyds你这个myds是个DataTable啊,不是应该定义成DataSet吗???
解决方案四:
如果你非要定义成DataTable,调用的时候应该这样myds.Rows[0][0].ToString();