hi
i have a table include 100 rows . i want read 20 (or any number less than 100) rows from the end of table and write rows by rows in a datagridview . what is the best way .
best means less commands
There are various data access technologies available, e.g. raw ADO.NET, typed DataSets, LINQ to SQL, Entity Framework, etc. I would suggest using raw ADO.NET to begin with because everything else is built on top of that. It's good to learn what's going on underneath so you can understand what the higher-level stuff is doing and how to fix it when it doesn't work. In your case, that means using a data adapter and calling its Fill method to populate a DataTable, which you can then bind to your grid. As for your query, you'll want to sort the data in reverse order and then, assuming SQL Server, use the TOP keyword to specify how many records to retrieve. Here are some ADO.NET examples of my own:
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.