OleDbDataReader
을 반복하고 요소를 ArrayList
에 넣는 방법은 무엇입니까?C#의 ArrayList에 대한 OleDbDataReader
여기 내 코드입니다 :
// ...
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;
여기에서 예외입니다 :
System.InvalidCastException: Unable to cast object of type 'System.Data.Common.DataRecordInternal' to type 'System.String'.
나는 그것을 얻지 않는다. 너 뭐하려고? 사용 가능한 모든 열의 문자열을 열 이름이나 유형에 관계없이 목록에 추가 하시겠습니까? – GSerg