shweta kulkarni

shweta kulkarni

  • NA
  • 7
  • 2.6k

Insert Query problem

May 15 2015 12:01 AM
Hi 
I have written query for inserting records in SQL daatbase from datagridview & some comboboxes & textboxes.
But it is given error like null expection was unhandled.
 
Please help to detect what is wrong in below code.
 
private void btnsubmit_Click(object sender, EventArgs e)
{
for (int i = 0; i < cnt; i++)
{
String str = "INSERT INTO JOB_Quality_Rating values('" + comboBox1.SelectedItem + "','" + comboBox3.SelectedItem + "','" + textBox1.Text + "','" + cmbtaskno.SelectedItem + "','" + comboBox2.SelectedItem + "','" + dataGridView1.Rows[i].Cells[0].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[1].Value.ToString() + "','" + dataGridView1.Rows[i].Cells[2].Value.ToString() + "','" + txtTotal.Text + "','" + mdlconnection.user_id + "','" + DateTime.Now + "')";
//int d = mdlconnection.excuteQuery(str);
//if (d > 0)
mdlconnection.excuteQuery(str);
{
MessageBox.Show("Job Quality Save sucessfully");
}
}
}
 
 

Answers (2)