Have you tried sqlTbl = new DataTable();
before starting your while loop?
An exception of type 'System.NullReferenceException' occurred
-
01-07-2022 - |
Domanda
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);
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow