早教吧 育儿知识 作业答案 考试题库 百科 知识分享

C#至少一个参数没有被指定值出错在oda.Fill(ds);protectedvoidPageLoad(objectsender,EventArgse){if(!Page.IsPostBack){stringsqlp="select*fromprovince";this.ddlProv.DataSource=DB.GetDS(sqlp);this.ddlProv.DataTextField=

题目详情
C#至少一个参数没有被指定值出错在oda.Fill(ds); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string sqlp = "select * from province"; this.ddlProv.DataSource = DB.GetDS(sqlp); this.ddlProv.DataTextField = "province"; this.ddlProv.DataValueField = "provinceID"; this.ddlProv.DataBind(); string sqlc = "select * from city where father=" + this.ddlProv.DataValueField; this.ddlCity.DataSource = DB.GetDS(sqlc); this.ddlCity.DataTextField = "city"; this.ddlCity.DataValueField = "cityID"; this.ddlCity.DataBind(); string sqla = "select * from area where father=" + this.ddlCity.DataValueField; this.ddlArea.DataSource = DB.GetDS(sqla); this.ddlArea.DataTextField = "area"; this.ddlArea.DataValueField = "areaID"; this.ddlArea.DataBind(); } } public static DataSet GetDS(string sql) { OleDbConnection con = DB.CreateCon(); con.Open(); OleDbDataAdapter oda = new OleDbDataAdapter(sql, con); DataSet ds = new DataSet(); oda.Fill(ds); return ds; }
▼优质解答
答案和解析
是SQL语句有列名或表名写错了,检查下。