日期:2014-05-16  浏览次数:20456 次

判断数据库表中字段是否为空
[size=medium]
string strSql = "select * from 表"
SqlDataReader reader = SqlHelper.GetDataReader(strSql);
if (reader.Read())
                {
                    DateTime? n = reader["userTime"] == DBNull.Value ? (DateTime?)null : (DateTime)reader["userTime"];
                    int? m = Convert.IsDBNull(reader["userName"]) ? (int?)null : int.Parse(reader["userName"].ToString());
                }
                else
                {
                    reader.Close();
                }

[/size]