Recent Articles

Open Source SQL Full Text Search Engine - Sphinx
CLR or TSQL? That is the question. More are more developers are struggling to find the right answer, but the answer really depends on the developer's individual needs. For classic SQL tasks, the good old TSQL is recommended. On the other hand, CLR works...

CLR Vs T-SQL And Stored Procedures In SQL Server
CLR or TSQL? That is the question. More are more developers are struggling to find the right answer, but the answer really depends on the developer's individual needs. For classic SQL tasks, the good old TSQL is recommended. On the other hand, CLR works best for calculations, parsing, image processing and...

MySQL Gets Telecom-Specific
Due to demand, MySQL AB announced the expansion of its telecom-specific services and consulting for MySQL software. Specifically, the company is promoting its MySQL Cluster, a high-end version of the standard database designed for fault-tolerant...

Practice Makes Perfect For SQL
MySQL guru Sheeri Kritzer listed eight SQL best practices for database professionals who are hard at work on their projects. Kritzer's list began with a preface on why she tries to live by the eight SQL rules in her post about...

Ingres Christens Project Icebreaker
The open source database company Ingres teamed with another open source player to deliver Icebreaker, a way to place database services on a server with no operating system required. Ingres CTO Dave Dargo blogged about Icebreaker, which launched recently during the LinuxWorld Conference and Expo. Dargo explained...

MySQL Turbo Manager And Dream Coder
The success and the longevity of any prominent business nowadays depend on powerful application infrastructures and effective, reliable management and development solutions. In present, a wide range of IT companies are striving to provide business owners...

11.21.06


Using DataTables More For Improving Performance

By Mads Kristensen

There are some features in the System.Data.DataTable class that a lot of developers don't utilize.

I base that statement on different code samples I've seen on blogs and article bases during the last couple of years. Some of these features can improve the performance.

Calculated columns

First of all, I'll create a DataTable manually, even though it is more likely to be created from querying a database.



Imaging that there is 100 rows in that DataTable and you now want to calculate total price of all item currently in stock. The calculation is Price*ItemsInStock. What I see in a lot of code samples is that this column is calculated in the database by a SQL statement like this:



The overhead in letting the database do the calculation is not that much in this particular example, because it is a simple multiplication of two rows. It could easily be more complicated than this example. The thing is, that .NET performs these kinds of calculation much more efficient than a database and that's why we would like .NET to do them.

Low Rate eCommerce & Retail Plans

The DataTable class supports on-the-fly calculated columns and they are perfect to use in the example. Just add another column to the DataTable and give it a calculation formula.



There a many different functions to use in the calculation expression.

Auto increment

Let's say you want to bind the DataTable to a DataGrid in an ASP.NET page and that you want a column to display the row number. This can be done by adding a column to the DataTable that has enabled the AutoIncrement property.

Click here to continue reading this article.


About the Author:
Mads Kristensen currently works as a Senior Developer at Traceworks located in Copenhagen, Denmark. Mads graduated from Copenhagen Technical Academy with a multimedia degree in 2003, but has been a professional developer since 2000. His main focus is on ASP.NET but is responsible for Winforms, Windows- and web services in his daily work as well. A true .NET developer with great passion for the simple solution.

http://www.madskristensen.dk/

About SQLproNews
SQLproNews is a collection of up to date tutorials and insightful articles designed to help SQL users of any skill level implement successful SQL systems and practices. SQL Strategies and Tactics for Business

SQLproNews is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
SQLproNews.com WirelessProNews.com
CProgrammingTrends.com SysAdminNews.com




-- SQLProNews is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2006 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal

advertising info | news headlines | free newsletters | comments/feedback | submit article


SQL Strategies and Tactics for Business SQLproNews News Archives About Us Feedback SQLproNews Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact