您好專家我使用此代碼前段時間,是工作,但現在不工作......!它說Value ComboBox更改TextBox的值在C#
(轉化爲varchar值 「System.Data.DataRowView」轉換爲數據類型爲int失敗時)
代碼下拉框中選擇價值變動文本框與此值的詳細信息並感謝你提前。
public partial class test : Form
{
SqlConnection cn = new SqlConnection("Server=AMEER;DataBase=custemer_net;Integrated security=true");
SqlDataAdapter da;
DataTable dt = new DataTable();
DataTable dttt = new DataTable();
public test()
{
InitializeComponent();
da = new SqlDataAdapter("Select *from subscrbtion ", cn);
da.Fill(dt);
comboBox1.DisplayMember = "name";
comboBox1.ValueMember = "id";
comboBox1.DataSource = dt;
}
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
da = new SqlDataAdapter("select * from subscrbtion where id='" + comboBox1.SelectedValue + "'", cn);
da.Fill(dttt);
textBox1.Text = dttt.Rows[0]["phone"].ToString();
}
您在這裏得到什麼錯誤/異常? –
謝謝親愛的我,但現在的錯誤對不起,錯誤 – ameer
錯誤何時下降?我假定在textBox1.Text = dttt.Rows [0] [「phone」]。ToString();另外,請在聲明數據和值成員 – Schuere