string IdDB = "select transid from transtbl where fullname = '"+textBox6.Text+"'";
con.SelectRec(IdDB, dt);
string IdDB2 = dt.Rows[0].ItemArray[0].ToString();
for (int rows = 0; rows < dataGridView2.Rows.Count; rows++)
{
int pProdID = int.Parse(dataGridView2.Rows[rows].Cells[0].Value.ToString());
string pProdName = dataGridView2.Rows[rows].Cells[1].Value.ToString();
double pPrice = double.Parse(dataGridView2.Rows[rows].Cells[2].Value.ToString());
int qQty = int.Parse(dataGridView2.Rows[rows].Cells[3].Value.ToString());
double tttTotal = double.Parse(dataGridView2.Rows[rows].Cells[4].Value.ToString());
string transdltdSql = "Insert into transdetailedtbl (transID, ProdID, ProdPrice, Qty, Total) value ("+int.Parse(IdDB2)+","+pProdID+","+pPrice+","+qQty+","+tttTotal+")";
con.ModRec(transdltdSql);
}
I get an error
System.NullReferenceException was unhandled HResult=-2147467261 Message=Object reference not set to an instance of an object.
anyone help me please. i was trying to execute query in a for loop but the value im getting is from the gridview.