我有这样的选择
object endTime = null;
string selectCommandText = "SELECT endtime FROM alapplication WHERE applicationid='" + application + "'";
DbProviderFactory dbf = DbProviderFactories.GetFactory("Npgsql");
using (IDbConnection conn = dbf.CreateConnection())
{
conn.ConnectionString = ASSettings.ConnectionInfo_MASTER;
conn.Open();
IDbCommand selectCommand = conn.CreateCommand();
selectCommand.CommandText = selectCommandText;
IDataReader reader = selectCommand.ExecuteReader();
if (reader.Read())
{
endTime = reader.GetValue(reader.GetOrdinal("endtime"));
}
reader.Close();
conn.Close();
conn.Dispose();
}
我想读取timezone类型的值endtime。问题是,有时这个值为null,然后当我读它时,我的结束时间就像这样
{}
所以它就像空的一样,既不是空的也不像是#34;"。我不知道如何检查它是否是这样的,因为如果它不是这样我可以尝试将它解析为像这样的日期时间
DateTime expireDate = DateTime.Parse(endTime.ToString());
现在我将查询更改为
string selectCommandText = "SELECT endtime FROM alapplication WHERE applicationid='" + application + "' AND endtime IS NOT NULL";
所以如果在db endtime中为null我将不会得到任何东西..但我想了解这件事,因为它发生在我身上其他时间..