我有一个具有修改按钮的表单是更新数据库中的现有数据。插入查询已成功执行但未插入数据
这是我使用的代码:
private void btnupdate_Click(object sender, EventArgs e)
{
try
{
int row = dataGridView1.RowCount;
for (int i = 0; i < row - 1; i++)
{
String str = "INSERT INTO JDS_Data(E_JDS_ID,E_JDS_Revision,DesignSpec,Engine_Type,Record_date,CPH_Designer,Exp_Del_Week,Rev_Description,Name_of_mock_up,EPC_Drawing,Turbocharger_no_Type,Engine_Specific_Requirement,Description_of_Job,SF_No,Standard,Task_No,SF_revision,Part_family,Action_code,Remark,Modified_Date,UserName) values('" + txtjobno.Text + "','" + comboBox1.SelectedItem + "','" + txtds.Text + "','" + txtenginetype.Text + "','" + dateTimePicker1.Text + "','" + txtcphdesigner.Text + "','" + txtexpweek.Text + "','" + txtrevdescription.Text + "','" + txtmockup.Text + "','" + txtepcdwg.Text + "','" + txtturbono.Text + "','" + txtenginereq.Text + "','" + txtdespjob.Text + "','" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[3].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[4].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[5].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[6].Value.ToString() + "','" + DateTime.Today.ToString("dd-MM-yyyy") + "','" + mdlconnection.user_name + "')";
int dd = mdlconnection.excuteQuery(str);
}
MessageBox.Show("Data Revised Successfully..!!!");
}
catch (Exception e2)
{
MessageBox.Show("" + e2.Message);
}
int rw = dataGridView2.RowCount;
for (int i = 0; i < rw - 1; i++)
{
String str = "INSERT INTO JDS_files(E_JDS_ID,SF_NO,PATH,Filename) values('" + txtjobno.Text + "','" + dataGridView2.Rows[i].Cells[0].Value.ToString() + "','" + dataGridView2.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView2.Rows[i].Cells[2].Value.ToString() + "')";
int dd = mdlconnection.excuteQuery(str);
}
btnupdate.Enabled = false;
}