SqlConnection con = DB.createConnection();
con.Open();
SqlCommand cmd = new SqlCommand("select * from Provinces",con);
SqlDataReader sdr = cmd.ExecuteReader();
this.ddlProvinces.DataSource = sdr;
this.ddlProvinces.DataTextField = "ProName";
this.ddlProvinces.DataValueField = "ProID";
this.ddlProvinces.DataBind();
sdr.Close();
SqlCommand citycmd = new SqlCommand("select * from City where ProID="+this.ddlProvinces.SelectedValue,con);
SqlDataReader citysdr = citycmd.ExecuteReader();
while(citysdr.Read())
{
this.lstCity.Items.Add(new ListItem(citysdr.GetString(1),citysdr.GetInt32(0).ToString()));
}
citysdr.Close();
下面是错误提示,请问错误是因为什么原因,为何错误呢??
行 87: while(citysdr.Read())
行 88: {
行 89: this.lstCity.Items.Add(new ListItem(citysdr.GetString(1),citysdr.GetInt32(0).ToString()));
行 90: }
行 91: citysdr.Close();