ahmed fahd

ahmed fahd

  • NA
  • 58
  • 45.9k

object reference not set to an instance of an object error

Jan 15 2013 7:21 AM
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:

Answers (2)