How to check empty DataTable

后端 未结 8 646
孤城傲影
孤城傲影 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:41

    Normally when querying a database with SQL and then fill a data-table with its results, it will never be a null Data table. You have the column headers filled with column information even if you returned 0 records.When one tried to process a data table with 0 records but with column information it will throw exception.To check the datatable before processing one could check like this.

    if (DetailTable != null && DetailTable.Rows.Count>0)
    

提交回复
热议问题