I have a DataSet which contains a datatable called Vacs and it has a date column called VacDate which in some cases it holds null value.
Now when i try to query it using linq query i got the following exception
The value for column \'VacDate \' in table \'Vacs\' is DBNull
My Code is:
var Vacs = new MyDataSetTableAdapter.MyVacsTableAdapter();
DataTable Vacations = Vacs.GetData()
.Where(s => s.VacDate == DateTime.Now)
.ToList()
.CopyToDataTable();
I did try the following but still getting the same error
DataTable Vacations = Vacs.GetData()
.Where(s => s.VacDate != null && s.VacDate == DateTime.Now)
.ToList()
.CopyToDataTable();
I believe the solution would be simple but still i dont see it till now.
Thank you in advance.
Best regards...
s.VacDate != DBNullinstead ofs.VacDate != nullVacDatenullable type?GetData()method? Also seems likeVacsis notDataTable- from naming it is something likeDataAdapter, but again there is noGetData()method in defaultDataAdapter.GetData()function body