OleDbDataReader to ArrayList in C#

How to iterate through OleDbDataReader and put its elements into ArrayList?

Here is my code:

// ...

ArrayList list = new ArrayList();

while(myReader.Read())
{
    foreach(string s in myReader) // I got an Exception here
    {
        list.Add(s);
    }
}

// ...

Label lbl = new Label();
lbl.Text = list[i] as string;

and here is the Exception:

System.InvalidCastException: Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.String'.

Answers


try this:

while (myReader.Read())
{
  list.Add(myReader.GetString(0));
}

Need Your Help

Typecasting asp.net webControl to generic type with onClick event

asp.net vb.net casting onclick

I'm trying to find a way in which I can create a collection of various webControl's and then add a "onClick" event handler to these various controls, i've tried creating a reimplementation of

How to fade the background

javascript html css

I was going to look up how to do this, but I don't really know what to call it to look it up, so I was hoping I could describe it here and someone could point me in the right direction.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.