问题描述
stringstrSelect="select*fromstudentwherestudent_ID='"+tb_studentID.Text+"'";SqlConnectionconn=newSqlConnection(strconn);conn.Open();SqlCommandcmd=newSqlCommand(strSelect,conn);SqlDataReaderdr=cmd.ExecuteReader(CommandBehavior.CloseConnection);while(dr.Read()){this.tb_StuID.Text=dr["student_ID"].ToString();this.tb_StuName.Text=dr["studnet_name"].ToString();this.tb_classID.Text=dr["class_ID"].ToString();this.combo_age.Text=dr["age"].ToString();this.combo_Sex.Text=dr["sex"].ToString();this.combo_specialty.Text=dr["specialty"].ToString();this.photo.Image=Image.FromFile(dr["picture"].ToString());this.combo_department.Text=dr["department_name"].ToString();this.combo_politic.Text=dr["politic"].ToString();}结果:未处理System.InvalidOperationExceptionMessage="在没有任何数据时进行无效的读取尝试。"请高手指点迷津!!