Ali  Alfaraj

Ali Alfaraj

  • NA
  • 66
  • 80.8k

object reference not set to an instance of an object error message

Jan 14 2011 11:40 PM

Good day!
When I run the following code, I got an error(object reference not set to an instance of an object ) related to the line of code coloured with red shown in the code below:  
Can anyone please help me with this error
 
private
void button2_Click(object sender, EventArgs e)
{
if (textBox2.Text == "" || textBox3.Text=="")
{
MessageBox.Show("?? ?? ?? ????? ??? ??????? ?????? ??????? ??? ????? ??? ?? ?????");
return;
}
a.bindingSource2.EndEdit();
a.???????TableAdapter.Update(a.cookbook1DataSet1.???????);
a.bindingSource3.EndEdit();
a.???????TableAdapter.Update(a.cookbook1DataSet1.???????);

int xx = dataGridView1.Rows.Count - 1;
for (int i = 0; i <= xx; i++)
{
 
// the error is here


textBox7.Text = dataGridView1.Rows[i].Cells[0].Value.ToString();

 
a.bindingSource4.EndEdit();
a.????????TableAdapter.Update(a.cookbook1DataSet1.????????);
a.bindingSource4.AddNew();
textBox6.Text = textBox2.Text;
 
}
a.bindingSource2.AddNew();
a.bindingSource3.AddNew();
textBox4.Text = comboBox1.Text;

}

 

Answers (2)