vb.net – 检查DataTable是否有行的有效方法

前端之家收集整理的这篇文章主要介绍了vb.net – 检查DataTable是否有行的有效方法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个搜索关键字然后返回DataTable的函数.我想检查里面是否有行,因为有时候找不到查询.
'which one shoud I use ?
    If dtDataTable Is Nothing Then
        'some code
        lbl_count.Text = "Found 0 result"
    End If

    If dtDataTable.Rows.Count > 0 Then
        'some code
        lbl_count.Text = "Found " & dtDataTable.Rows.Count.ToString & " results"
    End If

谢谢.

怎么样:
If dtDataTable IsNot Nothing AndAlso dtDataTable.Rows.Count > 0 Then
    'some code
    lbl_count.Text = "Found " & dtDataTable.Rows.Count.ToString & " results"
Else
    'some code
    lbl_count.Text = "Found 0 result"
End If
原文链接:https://www.f2er.com/vb/255593.html

猜你在找的VB相关文章