filling an array from a dataset

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello,

How can I declare an array, and set it to equal all the items in a column of
a dataset?

TIA,

Amber
 
I assume you want to copy the rows from a table in the DataSet, right? If
so, you need to manually loop through the rows and copy across to the array.
 
Here's one way:

' Populate dataset
SqlDataAdapter1.Fill(dataset1, "Categories")

' Create and dimension row array
Dim rows(dataset1.Tables("Categories").Rows.Count) As DataRow
' Loop through all rows in Categories table
For i As Integer = 0 To dataset1.Tables("Categories").Rows.Count - 1
rows(i) = dataset1.Tables("Categories").Rows(i)
Next
 
Back
Top