Question about adding columns to The DataSet?

Nsync

New member
Joined
Mar 6, 2005
Messages
2
Programming Experience
Beginner
i create as DataSet called Northwind and Table called Products

VB.NET:
Dim dsNorthwind As New DataSet("Northwind") 
Dim dtProducts As New DataTable("Products")
dsNorthwind.Tables.Add(dtProducts)

when i add a new column called ProductID

VB.NET:
Dim dcProductID As New DataColumn("ProductID")

what is the difference Between These two ways to adding The column and anyone is the better??

VB.NET:
dtProducts.Columns.Add(dcProductID) 
dsNorthwind.Tables("Products").Columns.Add(dcProductID)
:(
 
They both do the exact same thing.
In the first statement, you reference the dataTable diectly using dtProducts.
In the second, you reference the dataTable through the dataSet using it's Tables collection. ie: dsNorthwind.Tables("Products") = dtProducts since you created dtProducts with the name "Products" (Dim dtProducts As New DataTable("Products")) then added it to dsNorthwind's Tables collection (dsNorthwind.Tables.Add(dtProducts))
 
Back
Top