-1

I have a datagridview which is populated from a mysql db. It's basically checking for new entries in the db every minute. When it finds new records, it adds them all to the datagridview, then loops through each of them to check the data is correct, before processing whatever work needs doing based on the entry.

Here's what I've got at the moment:

Try
    Dim entryid As String = " "
    For Each row As DataGridViewRow In orderslist.Rows
        entryid = row.Cells("entry_id").Value.ToString
        If entryid <> "" Then

            Dim memberid As String = row.Cells("member_id").Value.ToString
            Console.WriteLine(entryid)

        End If

    Next
Catch ex As Exception
    MessageBox.Show(ex.ToString)
End Try

This works, in that I can see in the console a list of entryids; however, once it's looped through the last record in the db, I get a nullreferenceexception, presumably because its trying to check an empty row or something.

Is there a simple way around this?

neminem
  • 2,582
  • 5
  • 25
  • 35
John
  • 631
  • 1
  • 13
  • 34

1 Answers1

0

Found the answer guys

has to add this

    If row.Cells("member_id").Value.ToString IsNot Nothing Then

No more exception :)

John
  • 631
  • 1
  • 13
  • 34