Convert Datareader into ArrayList

Joined
Feb 25, 2008
Messages
5
Reaction score
0
Hi
I am trying to convert the datreader into ArrayList. The ArrayList consist of four columns But what i am all getting is All the data in one column with multiple rows. What i actually what is to store all the data in ArrayList with the same format as it appeared in datareader so that i can bound it with GridView.

My current code is given bellow:



Dim dr As SqlDataReader = cmd.ExecuteReader()
Dim al As New ArrayList

If (dr.HasRows) Then

While (dr.Read())

Dim fields As Integer = dr.FieldCount()
' Dim a As Integer

For fields = 0 To dr.FieldCount - 1
al.Add(dr.Item(fields))
Next
End While
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top