0
' Create two instances of the `DataTable` object to reference the two tables

Dim tblCategories As DataTable = DS.Tables("Categories")
Dim tblProducts As DataTable = DS.Tables("Products")

' Create two DataColumn objects to reference the columns on which the relation is based

Dim colCatCategoryID As DataColumn = tblCategories.Columns("CategoryID")
Dim colProdCategoryID As DataColumn = tblProducts.Columns("CategoryID")

When I get to Dim colCatCategoryID As DataColumn = tblCategories.Columns("CategoryID") I get the following error message:

Object reference not set to an instance of an object.

Blackwood
  • 4,461
  • 15
  • 28
  • 40
Enrique Bello
  • 25
  • 1
  • 1
  • 7
  • 1
    Debug your code. It sounds like there is no "CategoryID" column or no table named "Categories" in the DataSet. use your mouse to find out which one is `Nothing` – Ňɏssa Pøngjǣrdenlarp Jul 09 '16 at 16:08
  • BTW that first bit does not `Create two instances of the DataTable object` it attempts to create references to 2 *different* table objects. It is not clear why you need this since `DS.Tables(n)` is the same thing. – Ňɏssa Pøngjǣrdenlarp Jul 09 '16 at 16:20

0 Answers0