完成项目编辑并单击“保存”后,会导致错误。错误是:Fatal error encountered during command execution
详细信息会很棒。
private void btnSave_Click(object sender, EventArgs e)
{
if (textBox1.Text == "")
{
MessageBox.Show("VIN is Empty!", "Don't leave it blank!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
textBox1.Focus();
}
else if (MessageBox.Show("Do Want To Save it?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes)
{
Initialize();
connection.Open();
MySqlCommand cmd = new MySqlCommand();
cmd.CommandText = "Insert Into registration_form (VIN, Lst_name, Frst_name, Mddle_name, Sx, Hght, Wght, Address, Occupation, Brthday, Plceof_Birth, Cvl_Status, Nmeof_Father, Nmeof_Mother, Citizenship)" +
"Values (@VIN, @Lst_name, @Frst_name, @Mddle_name, @Sx, @Hght, @Wght, @Address, @Occupation, @Brthday, @Plceof_Birth, @Cvl_Status, @Nmeof_Father, @Nmeof_Mother, @Citizenship)";
cmd.Connection = connection;
cmd.Parameters.Add("@VIN",MySqlDbType.VarChar).Value=textBox1.Text.ToUpper();
cmd.Parameters.Add("@Lst_name",MySqlDbType.VarChar).Value=textBox2.Text.ToUpper();
cmd.Parameters.Add("@Frst_name",MySqlDbType.VarChar).Value=textBox4.Text.ToUpper();
cmd.Parameters.Add("@Mddle_name",MySqlDbType.VarChar).Value=textBox3.Text.ToUpper();
cmd.Parameters.Add("@Sx",MySqlDbType.VarChar).Value=comboBox1.Text.ToUpper();
cmd.Parameters.Add("@Hght",MySqlDbType.VarChar).Value=textBox6.Text.ToUpper();
cmd.Parameters.Add("@Wght",MySqlDbType.VarChar).Value=textBox7.Text.ToUpper();
cmd.Parameters.Add("@Address",MySqlDbType.VarChar).Value=textBox8.Text.ToUpper();
cmd.Parameters.Add("@Occupation",MySqlDbType.VarChar).Value=textBox9.Text.ToUpper();
cmd.Parameters.Add("@Brthday",MySqlDbType.VarChar).Value=dateTimePicker1.Text.ToUpper();
cmd.Parameters.Add("@Plceof_Birth",MySqlDbType.VarChar).Value=textBox11.Text.ToUpper();
cmd.Parameters.Add("@Cvl_Status",MySqlDbType.VarChar).Value=textBox5.Text.ToUpper();
cmd.Parameters.Add("@Nmeof_Father",MySqlDbType.VarChar).Value=textBox10.Text.ToUpper();
cmd.Parameters.Add("@Nmeof_Mohter",MySqlDbType.VarChar).Value=textBox12.Text.ToUpper();
cmd.Parameters.Add("@Citizenship", MySqlDbType.VarChar).Value = textBox13.Text.ToUpper();
MessageBox.Show("Record has been successfully saved", "Saved");
cmd.ExecuteNonQuery();
}
FillListView();
}
}
}
答案 0 :(得分:2)
设置此项以解决您的问题:
cmd.CommandTimeout = 5000000