//若从excel中读取的时间值为空值时,做如下转换
string YDKGSJ = string.Empty;
if (dbdata.Rows[i]["约定开工时间"].ToString() == "")
{
YDKGSJ = "null,";
}
else
{
YDKGSJ = "to_date(‘" + Convert.ToDateTime(dbdata.Rows[i]["约定开工时间"]) + "‘,‘yyyy-mm-dd HH24:MI:SS‘),";
}
在读取excel数据时,对于非string类型的字段做转换,注意空值类型的判断!!!!
//如double类型
//划拨土地总价款
double TDJK = 0;
if (dbdata.Rows[i]["划拨土地总价款"].ToString() == "")
{
TDJK = 0;
}
else
{
TDJK = Convert.ToDouble(dbdata.Rows[i]["划拨土地总价款"]);
}