Replicating GetRows in .NET


I believe .NET is the most exciting new development platform to date, with cumulative features surpassing many others as a whole. Migrating your legacy ASP code can be a daunting task given that you're learning as you go, but if you had some perusal of the framework it'll be a little less cumbersome. Of course with .NET, the ability to co-exist with legacy ASP code is fine, and you can even port in legacy code through the help of the exposing the legacy ADO components. But anyone serious about .NET would benefit themselves in taking full advantage of .NET and all it has to offer.

As you begin to delve deeper into the means of migrating your old code to .NET, you may run into a few stumbling blocks, and more so when you embark towards C# in particular, because of syntax differences and some VBScript/ASP coding methods you may have been accustomed to. In any event, one feature I have found to be missing in sorts in migration is the simple ADO method of GetRows which copies your data results into an two-dimensional variant array in the form of recordset.GetRows(Rows, Start, Fields) .

In .NET however this exact method is not to be found, or is it? Well it is…kind of. Now, most people learning .NET upon first view might see a general template driven approach in which applications can be developed. They learn about DataGrids, Web controls, code-behind, data readers, and so on, so this all may give the immediate impression of developmental building blocks without much precise control of one's code. Well nothing could be further from the truth. Replicating GetRows in .NET is easier than you think and it gives you precise control in the detail of your data and its display. Having said that, one feature not available with this method is the implemention of the NextRecordSet feature, whereby multiple batch SQL statements can be consecutively run. Nevertheless, the .NET DataReader duplicates this functionality with Reader.NextResult() , but not within the context of this example.

This article at the very least will inform you about the DataTable object and how to use it.

To now get back on track, let's explore the classic ASP method of displaying a table of data with GetRows and then replicate it exactly in .NET.

You might also like...


About the author

Dimitrios Markatos

Dimitrios Markatos United States

Dimitrios, or Jimmy as his friends call him, is a .NET developer/architect who specializes in Microsoft Technologies for creating high-performance and scalable data-driven enterprise Web and des...

Interested in writing for us? Find out more.


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“The most exciting phrase to hear in science, the one that heralds new discoveries, is not 'Eureka!' but 'That's funny...'” - Isaac Asimov