List Info

Thread: how to programatticaly create schema to add a data row




how to programatticaly create schema to add a data row
user name
2006-09-28 17:21:13
I have a dataset that will have two columns of data (UPC,
NumberTimesSCanned).

I go through this dataset and get three more bits of
information about
the UPC..

 

I need to return a single consolidated dataset with all five
fields in
it. I thought I would do something like the code below, but
it has a
problem because the schema of the datatable is not defined.
Without
declaring a strongly typed dataset, how could I accomplish
something
like this ?

 

Dim dsNoSound As DataSet = GetNoSoundItems(StoreNumber)

            Dim iLoop As Integer

 

            Dim dsTable As New DataTable

            For iLoop = 0 To dsNoSound.Tables(0).Rows.Count
- 1

                Dim thisUPC As String =
CStr(dsNoSound.Tables(0).Rows(iLoop).Item("UPC"))

                Dim thisQty As Integer =
CInt(dsNoSound.Tables(0).Rows(iLoop).Item("NumberTimesS
canned"))

                Dim dsInfo As DataSet =
GetCfgCatDescForItem(thisUPC,
StoreNumber)

                Dim dr As DataRow = dsTable.NewRow

                dr.Item(0) = thisQty

                dr.Item(1) = thisUPC

                dr.Item(2) =
CStr(dsInfo.Tables(0).Rows(0).Item("POSDesc"))

                dr.Item(3) =
CStr(dsInfo.Tables(0).Rows(0).Item("AlphCfg"))

                dr.Item(4) =
CStr(dsInfo.Tables(0).Rows(0).Item("CAT"))

                dsTable.Rows.Add(dr)

            Next

            Dim dsResult As DataSet = New DataSet

            dsResult.Tables.Add(dsTable)

            Return dsResult

 

Stacey

 


===================================
This list is hosted by DevelopMentorŪ  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )