This works...
if(searchDate!=null) {
cmdP0.Parameters["@Medical"].Value=searchDate;
}else{
cmdP0.Parameters["@Medical"].Value=DBNull.Value;
}
so why does the compiler not allow...
cmdP0.Parameters["@Medical"].Value = searchDate!=null searchDate:DBNull.Value;
------------------
I've been having trouble getting null values into my table when getting anything but text (eg ints & dates) from my textboxes
This code helped solved part of the problem
string inputDate = txtmDoLM.Text;DateTime searchDate = null;
if(!string.IsNullOrEmpty(inputDate)) {
DateTime date;
if(DateTime.TryParse(inputDate , out date))
searchDate = date;
}
} I couldn't use DBNull.Value in place of null - this really is driving me mad.