如何将文本转换为整数?

时间:2019-07-15 14:31:52

标签: c#

我试图更新我的表,但出现了这样的异常:“格式不正确”(英文,“输入字符串格式不正确”)。数字?

public cordonnes(String tel, String adresse, String password)
{
    InitializeComponent();
    textBox1.Text = tel;
    textBox2.Text = adresse;
    textBox3.Text = password;
}

private void button1_Click(object sender, EventArgs e)
{
    if (textBox1.Text == "" || textBox2.Text == "" || textBox3.Text == "")
        MessageBox.Show("SVP Veuillez remplir tous les champs ");
    else
    {
        SqlConnection con = new SqlConnection(connectString);
        con.Open();
        int text2 = System.Convert.ToInt32(textBox2.Text);
        string cmdString = "update inscrit set adresse ='" + textBox1.Text + "',tel='" + text2 + "' , password ='" + textBox3.Text + "'";
        SqlCommand cmd = new SqlCommand(cmdString, con);

0 个答案:

没有答案
相关问题