Home All Groups Group Topic Archive Search About

Datatable = dataset.Tables("Supplier") ?

Author
28 Aug 2006 6:08 PM
Tom W
code snipped from MS sample "N-Tier Data Form and Data Layer" example
(101 vb.net samples).

Public Class frmMain
Private dsSupplierProducts as DataSet
Private dtSupplier as DataTable
Private dtProducts as DataTable
Private dvSupplier as DataView
Private dvProduct as DataView

Sub GetDateSet()
   m_DAL = new DataAccess  ()    'Data access tier.
   dsSupplierProducts = m_DAL.CreateDataSet()  ' this returns one
dataset with two tables, Supplier & Products

   'Set variables for the DataTables for use later
   dtSupplier = dsSupplierProducts.Tables("Supplier")
   dtProducts = dsSupplierProducts.Tables("Products")

   'Set up Dataviews for the datagrid
   dvSupplier = dtSupplier.DefaultView
   dvProduct as dtProducts.DefaultView
end Sub

Sub BindProductsGrid()
   ....
   dvProducts.RowFilter = "Suppliers = " & strCurrentSupplierID

   With grdProducts
       .CaptionText = "whatever"
       .DataSource = dvProducts
   end With

End Sub


What I don't understand are the lines
dtSupplier = dsSupplierProducts.Tables("Supplier")
dtProducts = dsSupplierProducts.Tables("Products")

Do these assignments populate separate, distinct datatables with the two
tables from the dataset?  IE: the data now exists in two places?
Or are the datatables just pointers to the original dataset.datatables
(dsSupplierProducts.Tables(".."))?

Changes made to data in the grids is passed back to the data access tier
like:
m_DAL = new DataAccess()
m_DAL.UpdateDataSet(dsSuppliersProducts.GetChanges())


Thanks
Tom

--



E-mail correspondence to and from this address may be subject to the
North Carolina Public Records Law and may be disclosed to third parties.

Author
28 Aug 2006 7:03 PM
GhostInAK
Hello Tom,

dtSupplier and dtProducts should both be references to their respective tables
in dsSupplierProducts.  Any changes made to one should be reflected in the
other.

-Boo

Show quoteHide quote
> What I don't understand are the lines
> dtSupplier = dsSupplierProducts.Tables("Supplier")
> dtProducts = dsSupplierProducts.Tables("Products")
> Do these assignments populate separate, distinct datatables with the
> two tables from the dataset?  IE: the data now exists in two places?
> Or are the datatables just pointers to the original dataset.datatables
> (dsSupplierProducts.Tables(".."))?
>
> Changes made to data in the grids is passed back to the data access
> tier
> like:
> m_DAL = new DataAccess()
> m_DAL.UpdateDataSet(dsSuppliersProducts.GetChanges())
> Thanks
> Tom