SqlConnection myconnection=new SqlConnection("Server=localhost;uid=sa;pwd=;database=qdsalt");
String mysqlstr="Select name,age,qushi,sfzhm,dwmc,dz,dh,yyzzh,nxl,sqsj,spjd from information where yhm=@yonghuming";
SqlCommand mycom=new SqlCommand(mysqlstr,myconnection);
mycom.Parameters.Add(new SqlParameter("@yonghuming",SqlDbType.NVarChar,50));
mycom.Parameters["@yonghuming"].Value=Session["yonghuming"];
myconnection.Open();
SqlDataReader myread;
myread=mycom.ExecuteReader();
if(myread.GetString(0)=="待审批")
{
while (myread.Read())
{
TextBox1.Text=myread.GetString(0);
TextBox2.Text=myread.GetString(1);
DropDownList1.SelectedValue=myread.GetString(2);
TextBox7.Text=myread.GetString(3);
TextBox3.Text=myread.GetString(4);
TextBox4.Text=myread.GetString(5);
TextBox8.Text=myread.GetString(6);
TextBox5.Text=myread.GetString(7);
TextBox6.Text=myread.GetString(8);
TextBox12.Text=myread.GetString(8);
}
}
else
{

}
myread.Close();
myconnection.Close();
出现问题System.InvalidOperationException: 在没有任何数据时进行无效的读取尝试。