How do you populate an array with dataset values
-
I am using VB 2005 and have connected to an Access database. Rather than do the usual for i = 0 to total, can you populate an array with the dataset some how.
Do you want an array filled with the tables the DataSet contains? If so, and if you have included the System.Linq namespace, then you can use
ds.Tables.ToArray()
, where ds is your DataSet. The result of that method call will be the Tables property as an array -
I am using VB 2005 and have connected to an Access database. Rather than do the usual for i = 0 to total, can you populate an array with the dataset some how.
Or if you want to enter the values of a certain column from the dataset into the array you can use the
For Each
loop:For Each rw As DataRow In YourDataSet.Table("WhatEverTable").Rows
Or considering that a dataset, in a sense, is a sophisticated array, you could consider forgetting about copying values to an array first, and just get them straight from the dataset.
My advice is free, and you may get what you paid for.