cell(Datetime)の値を空または "None"と比較したい。空でないか、それ以外の場合はパラメータを追加する。あなたの助けのDatetimeの値をCのヌルまたは特定のテキストと比較する#
おかげで、それは私が
command.Parameters.AddWithValue("@pin", row.Cell(2).GetValue<string>());
command.Parameters.AddWithValue("@Amount", row.Cell(3).GetValue<int>());
if(row.Cell(4).GetValue<DateTime>() == "" || row.Cell(4).GetValue<DateTime>() =="none")
{
}
command.Parameters.AddWithValue("@Expirydate", row.Cell(4).GetValue<DateTime>());
command.ExecuteNonQuery();
これはExcelファイルのようなスプレッドシートに関するものですか? – Jake
可能な複製:http://stackoverflow.com/a/4604459/3270427 – McNets
Yeas、Jake Excelシートからデータを読み取っています –