Dataset into array

P

Poppy

Can someone point me to an example of populating an array from either a
dataset or a datareader ?

This .net stuff is killing me.
 
G

Gerry O'Brien [MVP]

Try this, assuming your data can be a string;

Dim arData() As String
Dim ds As New DataSet
' Fill your dataset in your own way here

ReDim arData(ds.Tables(0).Rows.Count)

For intCounter As Integer = 0 To ds.Tables(0).Rows.Count - 1
arData(intCounter) = ds.Tables(0).Rows(intCounter).Item(0).ToString

Next
 
A

Ashish M Bhonkiya

Hi,

Following code will help you to populate the data from the datareader in to
an arraylist.

ArrayList rowList = new ArrayList();
SqlDataReader reader = storedProcCommand.ExecuteReader();
while (reader.Read())
{
object[] values = new object[reader.FieldCount];
reader.GetValues(values);
rowList.Add(values);
}



10Cents
Regards
Ashish M Bhonkiya
 
P

Poppy

Thanks All

Much Appreciated.


Ashish M Bhonkiya said:
Hi,

Following code will help you to populate the data from the datareader in to
an arraylist.

ArrayList rowList = new ArrayList();
SqlDataReader reader = storedProcCommand.ExecuteReader();
while (reader.Read())
{
object[] values = new object[reader.FieldCount];
reader.GetValues(values);
rowList.Add(values);
}



10Cents
Regards
Ashish M Bhonkiya

Poppy said:
Can someone point me to an example of populating an array from either a
dataset or a datareader ?

This .net stuff is killing me.
 

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
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top