Register  |  Login
Search:      
May 19, 2012
Forum Minimize
 
  NMUG Discussion Forums  .NET Language D...  VB  Dealing with datatables without headers
Disabled Previous
 
Next Disabled
New Post 11/9/2010 5:35 PM
User is offline CCarroll
2 posts
www.desertsea.com
Posts are coming!


Dealing with datatables without headers 

Hello All,

I need to iterate through a filled datatable and create a second datatable with rows of fields derived from the raw data (doing math and things along the way).

da.Fill(dsFullCard.Tables(0))



            Dim row As DataRow

            For Each row In dtRawCard.AsEnumerable()
                With dtCard.NewRow
                    .Item(0) = dtRawCard.Rows.Item(3)

The line: da.Fill(dsFullCard.Tables(0)) works and a datatable ("dtRawCard") is sitting there all nice and full of data with no headers.  DataTable Visualizer shows them as F1, F2...(even though 0 based, but, whatever...)

My question is: how do you address the fields in a datatable with no headers?

I know ".Item(0) = dtRawCard.Rows.Item(3)" tries to cast (in this case) a uInt16 -> a Rows object which is wrong--along with about 300 other variations I've tried.  Anybody know what is right?

(Hopefully the answer to addressing fields will also apply to queries in Linq to datasets, which I'll be getting to next :O)

Appreciate any advice.

Charlie

 
New Post 11/11/2010 8:13 AM
User is offline CCarroll
2 posts
www.desertsea.com
Posts are coming!


Re: Dealing with datatables without headers 

After days of fishing around intellisense and pure trial and error --  (and with no thanks to the now utterly worthless new MSDN "Help" - not a single article referred to even the existance of a "DataReader") --  CreateDataReader is the (or at lease one) answer:

For Each row In dtRawCard.AsEnumerable()
                            dtRawCard.CreateDataReader()
                            With dtCard.NewRow
                                .Item(0) = reader.GetValue(3)
                                surf = reader.GetValue(8) etc., etc.

 
Disabled Previous
 
Next Disabled
  NMUG Discussion Forums  .NET Language D...  VB  Dealing with datatables without headers
Print  
Our Sponsors Minimize
Print