the datatable in this code give me error of
object reference not set to an instance of an object
Dim dt As DataTable = New DataTable
dt = DataGridView1.DataSource
For a = 0 To DataGridView1.Rows.Count - 1 Step 1
If a = DataGridView1.Rows.Count - 1 Then
GoTo v
End If
'myobjects._emp_num = DataGridView1.Rows(a).Cells(0).Value
myobjects._emp_num = dt.Rows(a)("emp_id")
myobjects._emp_name = dt.Rows(a)("emp_name")
myobjects._emp_situation = dt.Rows(a)(3)
myobjects._day_date = dt.Rows(a)(2)
com.add_al7door(myobjects)
Next
v:
Object reference not set to an instance of an object error
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Anurag SarkarRank #1,049 · 1.8K reputationPosted Jan 15, 2013, 2:25 AM EST
ahmed fahd57 reputationPosted Jan 15, 2013, 2:38 AM EST
I USED THAT THIS ERROR APPEAR THEN I DONT SAY (NEW )WHEN I DEFINE THE OBJECT
BUT I SAID THE NEW WORD BUT I DON'T KNOW WHAT ERRORS CAON BE OTHER THAT