判断数据库表中字段是否为空

[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]

你可能感兴趣的:(C++,c,C#)