table size

I'm a newbie.

in C#

If I add and delete, to and from my table, how can I detemine the number of records in my table at any given time.

What I want to do is to read only the last 50 records of my tabel so I will only see the latest entries.

Any help is greatly appreciated.

Jim Diamond



Answer this question

table size

  • Eric J. Smith

    I'm assuming here that you have a SQL Server backend or something like that. The easiest way would be something like

    SELECT TOP 50 * FROM Table1 ORDER BY anIDField DESC

    Where anIDField is either an autoincrement field or a datetime field [I'd prefer a datetime field just because you know WHEN the record was added].


  • urw

    I have resolved my problem.

    the code I was looking for is:

    oleDbDataAdapter1.Fill(words1DataSet1, "Words17");

    bm1 = this.BindingContext[words1DataSet1, "Words17"];

    if (words1DataSet1.Words17.Count > 50)

    bm1.Position = words1DataSet1.Words17.Count - 50;

    else

    bm1.Position = 0;

    The keyword I needed was Count.

    Thank you for trying to help me.

    Jdiamond


  • table size