数据库 插入时 碰到NULL报错判断的一种方法(技巧)
时间:2021-07-01 10:21:17
帮助过:3人阅读
public static object ToDBNull(object value) 判断插入数据的时候个别参数不能为空的时候做的判断方法
//{
// if (value == null)
// {
// return ToDBNull.Value;
// }
// else
// {
// return value;
// }
}
static void Main(
string[] args)
{
// new SqlParameter(@"BirthDay",ToDBNull(BirthDay)), 方法调用的方法。内容只是截取方法,并不是完整的数据库插入语句
//完整的看图片信息
字符类型后面添加?代表允许数据为 空==Null;





数据库 插入时 碰到NULL报错判断的一种方法(技巧)
标签: