Hi,
I have a datreader object with 100 rows, i created a collection object[ arraylist / hashtable] and stored all the rows to the collection object.
I dont want to keep the connection opened that's the reason i stored the data to the collection object and killed the datareader object.
But the problem is I wanted to retrieve the value using column names not by index. For this I looped thru the column names from datareader, how do I merge these two objects
Any help is highly appreciated.

DataReader rows into a collection object
horatiug
The datareader gets the data....the datatables persist the data in structured memory...you can also utilize custom classes/objects (business entities) to do the same thing as a datatable...
<quote>But the problem is I wanted to retrieve the value using column names not by index. For this I looped thru the column names from datareader, how do I merge these two objects </>
While MyReader.Read
For x As Integer = 0 To Myreader.FieldCount - 1 MyObject.FieldArray(x) = Myreader(x) Next
loop
If you want to do this with column names then I would suggest using an array of names also....something like this:
While MyReader.Read
For x As Integer = 0 To Myreader.FieldCount - 1 MyObject.FieldArray(x) = Myreader(MyColumnNames(x)) Next
loop
HAFB
arunr2002
http://codebetter.com/blogs/grant.killian/archive/2004/03/23/9819.aspx
Or you could just run the SQL to populate the DataTable directly. I find this much easier ...
Josh
Hf Kok
We don't use datatables in our application, we use custom objects.