Select TOP 5 * from SomeTable, using Dataview.RowFilter ?

Posted by eugeneK on Stack Overflow See other posts from Stack Overflow or by eugeneK
Published on 2010-04-13T07:22:41Z Indexed on 2010/04/13 7:22 UTC
Read the original article Hit count: 514

Filed under:
|
|

I need to select 5 most recent rows from cached Dataview object, is there any way to do that?

I've tried but Indexer DataColumn is empty. :

public static DataView getLatestFourActive()
{
    DataTable productDataTable = getAll().ToTable();
    DataColumn ExpressionColumn = new DataColumn("Indexer",typeof(System.Int32));
    ExpressionColumn.Unique = true;
    ExpressionColumn.AutoIncrement = true;
    ExpressionColumn.AllowDBNull = false;
    ExpressionColumn.AutoIncrementSeed = 0;
    ExpressionColumn.AutoIncrementStep = 1;
    productDataTable.Columns.Add(ExpressionColumn);

    DataView productFilteredView = productDataTable.DefaultView;
    productFilteredView.RowFilter = "isActive=1 and Indexer<4";
    return productFilteredView;
}

getAll() returns cached DataView

thanks

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about ADO.NET