如何把文本框得到的数据转换成int型呢SqlCommand cmd = new SqlCommand("Select * from t09.cfnr where dnbxlh = @id", con);
            SqlDataAdapter adp = new SqlDataAdapter(cmd);
            cmd.Parameters.AddWithValue("@id",textBox1.Text);因为dnbxlh是int型的

解决方案 »

  1.   

    Convert.ToInt32(textBox1.Text)强制转换
      

  2.   

    (int)textbox1.text  也行的吧
      

  3.   

               int _Value = 0;
    if (int.TryParse(textBox1.Text, out _Value))
    {    SqlCommand cmd = new SqlCommand("Select * from t09.cfnr where dnbxlh = @id", con);
        SqlDataAdapter adp = new SqlDataAdapter(cmd);
        cmd.Parameters.AddWithValue("@id", _Value);
    }