C# 读取Sql Server中的NULL返回什么?

165 阅读1分钟

我们在读取数据库中的NULL数据时候,用什么判断呢? 在这里插入图片描述

转换为字符串时候用 "" 判断,千万别用 null,完坑!

string free = dr["free"].ToString();

if (free == "")
{
    continue;
}

// 宝友,这可不行啊
if (free == null)
{
    continue;
}