如何检查数据行值为null

编程入门 行业动态 更新时间:2024-10-10 13:24:50
本文介绍了如何检查数据行值为null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

请告诉我是这是检查NULL在DataRow中,如果需要返回一个字符串

Convert.ToString(行[Int64_id] ??)

还是应该像检查与DBNull.Value。

需要这么多比

如果(行[Int64_id]!= DBNull.Value){...}否则,如果{}

解决方案

检查数据列不为null与的DataRow.IsNull(string COLUMNNAME)

如果( !row.IsNull(Int64_id)) { //这里你可以使用它安全长someValue中=(长)行[Int64_id]; }

Tell me please is this is correct way to check NULL in DataRow if need to return a string

Convert.ToString(row["Int64_id"] ?? "")

Or should be like check with DBNull.Value.

Need to so much more smaller than

if(row["Int64_id"] != DBNull.Value){...}else if{}

解决方案

Check if the data column is not null with DataRow.IsNull(string columnName)

if (!row.IsNull("Int64_id")) { // here you can use it safety long someValue = (long)row["Int64_id"]; }

更多推荐

如何检查数据行值为null

本文发布于:2023-07-21 06:05:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1174851.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:值为   数据   null

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!