Fehler: Vergleich row==System.DBNull DBNull is
a type, which is not valid in the given context
Fehler:
Severity
|
Code
|
Description
|
Error
|
CS0119
|
'DBNull'
is a type, which is not valid in the given context
|
string sMonth01 =
ProductDate.dtMonth.ToString("yyyy-MM-01");
if
(row[sMonth01] == System.DBNull) {
row[sMonth01] =
ProductDate.dtMonth.ToString("yyyy-MM-dd");
}
else
{
row[sMonth01] = row[sMonth01]
+ ",
" +
ProductDate.dtMonth.ToString("yyyy-MM-dd");
}
|
Lösung:
row[sMonth01] is
System.DBNull
|
string sMonth01 =
ProductDate.dtMonth.ToString("yyyy-MM-01");
if (row[sMonth01] is
System.DBNull) {
row[sMonth01] =
ProductDate.dtMonth.ToString("yyyy-MM-dd");
}
else
{
row[sMonth01] = row[sMonth01]
+ ",
" +
ProductDate.dtMonth.ToString("yyyy-MM-dd");
}
|