Returning n number of rows in datatable format from datatable object

Răspuns Returning n number of rows in datatable format from datatable object

  • 16 aprilie 2012 10:04
     
     
    I am using following code to return n number of rows from DataTable to another DataTable object. It is working fine when in first datatable records comes from database but when I mannualy added records in datatable then it crash and a message displays no rows.
    I had debugeed and found that currentTable.DefaultView.ToTable().Rows.Cast<DataRow>() this will returns null value.
    I had written following code to select n records from DataTable object

        currentTable = currentTable.DefaultView.ToTable().Rows.Cast<DataRow>().Take(numberOfRecord).CopyToDataTable();

    I dont know why it is crashed when I manualy creating DataTable and working fine when records comes from DataReader to DataTable.

Toate mesajele