Sulla linea: bool travel = fill.travel.Value;
Sto ottenendo il seguente errore:L'oggetto Nullable deve avere un valore?
Nullable object must have a value
e io non sono sicuro perché. Tutto quello che voglio fare è ottenere il valore nel database di viaggio che è attualmente falso. Qualsiasi aiuto sarebbe apprezzato.
using (var db = new DataClasses1DataContext())
{
var fill = (from f in db.expenseHdrs
where f.rptNo == getPkRowReport()
select f).FirstOrDefault();
txtReportDesc.Text = fill.description;
txtPeriod.Text = fill.period;
txtPurpose.Text = fill.purpose;
bool travel = fill.travel.Value;
chkTravel.Checked = travel
}
ciò che 'getPkRowReport' tornare? –
Sembra che fill.travel sia un bool nullable ('bool?'), Ed è NULL nel database. – driis
@driis, questa è la risposta, quindi tanto vale spostarla in basso. –