最好的方法来处理Datarow DBNull [英] Best way to handle Datarow DBNull

查看:630
本文介绍了最好的方法来处理Datarow DBNull的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

检查数据表中是否有空值的最佳方法

我想知道应该如何检查DBTull的DataTable - DataRow值。

I want to know what should be the way to check DBNull for a DataTable - DataRow values.

我有一个DataRow从数据库中获取行类型的信息:

I have a DataRow which fetches information from database from rows type like :

varchar,money,Int等。

varchar, money, Int and so on.

我应该用什么方法来处理这种情况。

What should be my (simple and sweet) approach to handle such situation.

推荐答案

尝试:

foreach(DataRow row in table.Rows)
{
    object value = row["ColumnName"];
    if (value == DBNull.Value)
    {

    }
    else
    {
    }
}

这篇关于最好的方法来处理Datarow DBNull的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆