Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


How to save data in a dataset to an array

nguyenvnguyenv Member Posts: 4
Hi Everyone,

Can someone please tell me how to save a data from a dataset into an array? I had a dataset with 2 tables (Polyin, and Test) in it. One with four columns and four rows. The other with nine columns and four rows. I try the following codes

Dim MaxRowsTap As Integer = 4
Dim MaxColumnsTap As Integer = 4
Dim inc, inc2 As Integer
MaxRowsTap = DataSet.Tables("Polyin").Rows.Count
MaxColumnsTap = DataSet.Tables("Polyin").Columns.Count

For inc = 0 To MaxRowsTap - 1
For inc2 = 0 To MaxColumnsTap - 1
xy(inc, inc2) = DataSet.Tables("Polyin").Rows(inc).Item(inc2)

Dim MaxRows As Integer = 4
Dim MaxColumns As Integer = 9
Dim inc3, inc4 As Integer
MaxRows = DataSet.Tables("Test").Rows.Count
MaxColumns = DataSet.Tables("Test").Columns.Count

For inc3 = 0 To MaxRows - 1
For inc4 = 0 To MaxColumns - 1
xy(inc3, inc4) = DataSet.Tables("Test").Rows(inc3).Item(inc4)

and after I run this program, I got an error message liked this " An unhandled exception of type 'System.IndexOutOfRangeException' occurred in Test.exe

Additional information: Index was outside the bounds of the array.

Please advise!!!

Thank you for your helps in advance,

Vy Nguyen

Sign In or Register to comment.