This is my code,
public DateTime GetStartDateforCriteria(string criteriaid)
{
try
{
DateTime sdate = new DateTime();
DataSet dset = new DataSet();
cSqlStr = "select CriteriaId from SMS_Published_Criteria where CriteriaId=@criteriaid";
dset = SqlHelper.ExecuteDataset(AppDB, CommandType.Text, cSqlStr, new SqlParameter("@criteriaid", criteriaid));
if (dset != null && dset.Tables.Count != 0 && dset.Tables[0] != null && dset.Tables[0].Rows.Count > 0)
{
cSqlStr = " select ValidityStartDate from SMS_Published_Criteria where VersionNumber=(select max(VersionNumber) from SMS_Published_Criteria) and CriteriaId =@criteriaid";
sdate = (DateTime)SqlHelper.ExecuteScalar(AppDB, CommandType.Text, cSqlStr, new SqlParameter("@criteriaid", criteriaid));
}
else
{
}
return sdate;
}
catch (Exception ex)
{
throw;
}
}
if dset empty means,i want to set sdate=null in else part.but it shows
"Cannot convert null to 'DateTime' because it is a non-nullable value type".
How can i set sdate=null? can anyone help me?