I am encountering error that says:
System.NullReferenceException: 'Object reference not set to an instance of an object.'
on the 3rd line of this Button's code:
ReadAllProductsList dbproduct = new ReadAllProductsList();
DB_ProductsList = dbproduct.GetAllProducts();//Get all DB contacts
if (DB_ProductsList.Count > 0)
{
btnDelete.IsEnabled = true;
}
listBoxobj.ItemsSource = DB_ProductsList.OrderByDescending(i => i.Id).ToList();
I am not sure why this is happening. Is my database actually created?
When I remove the if statement and its body, I get another error that says:
Value cannot be null
on line
listBoxobj.ItemsSource = DB_ProductsList.OrderByDescending(i => i.Id).ToList();
Does it mean the table of database is not really there?
But on the adding new product form I don't get any error though, so I am guessing the DB is there.