How to check empty DataTable

后端 未结 8 586
孤城傲影
孤城傲影 2020-12-10 10:15

I have a DataSet where I need to find out how many rows has been changed using the following code:

dataTable1 = dataSet1.Tables[\"FooTable\"].Ge         


        
相关标签:
8条回答
  • 2020-12-10 10:57

    As from MSDN for GetChanges

    A filtered copy of the DataTable that can have actions performed on it, and later be merged back in the DataTable using Merge. If no rows of the desired DataRowState are found, the method returns Nothing (null).

    dataTable1 is null so just check before you iterate over it.

    0 讨论(0)
  • 2020-12-10 10:59

    This is an old question, but because this might help a lot of c# coders out there, there is an easy way to solve this right now as follows:

    if ((dataTableName?.Rows?.Count ?? 0) > 0)
    
    0 讨论(0)
提交回复
热议问题