문제

I am trying to load a dataTable with a dataReader but for this simple process i am getting following error:

An exception of type 'System.NullReferenceException' occurred in project.dll but was not handled in user code. Additional information: Object reference not set to an instance of an object.

My Code:

while (dtaRdr.Read())
{
   testVar = dtaRdr.GetValue(5).ToString(); //DataExists.
}
sqlTbl.Load(dtaRdr);
도움이 되었습니까?

해결책

Have you tried sqlTbl = new DataTable(); before starting your while loop?

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top