Problem with dataportal.Fetch (i think)Problem with dataportal.Fetch (i think)
Old forum URL: forums.lhotka.net/forums/t/6817.aspx
lmatovic posted on Friday, April 17, 2009
hey all,
i have some problem and don't know what to do,maybe someone could help. In one class i have a static method that returns a datatable from database (i'm using data access application block). And then, in Business class i call that method and store datatable. Problem is when want to iterate through rows i get an error:
"DataPortal.Fetch failed ( Object reference not set to an instance of an object )
And it points to the "foreach" statement
foreach (var row in dt.Rows)
{
int br = System.Convert.ToInt32(((DataRow)row)["Id"]);
Console.Write(br);
this.Add(product.returnProduct(br));
}
I really don't know what to do or wher the problem is. I would appreciate any help.
LukaRockfordLhotka replied on Monday, April 20, 2009
You should use the debugger to find out what is null. Probably the DataTable from the look of your code.Copyright (c) Marimer LLC