I am reading 2 tables in T-SQL like so:
Select r.UID,c.Forename,c.Surname,c.DOB From c LEFT OUTER JOIN r on........
Then in VB.NET I loop through the dataset like so:
For Each drR In dsR.Tables(0).Rows......Next
However when I test like so:
If Convert.IsDBNull(drR("r.UID")) Then
Or
String.IsNullOrEmpty(drR("r.UID"))
Convert.IsDBNull(r.UID))
I crash with
Column 'UID' does not belong to table row
when the second table r has no record.
I did try both r.UID and UID.
To recoup: All is fine when I have a record in the second table, but what must I do when I do not? How do I test for DBNull so as not to crash with "Column .... does not belong to table row"?
P.S. Regardng the 2 answers below: I have to test for UID so as to know whether there is a record in the 2nd table or not.