Home > Articles > Programming > Windows Programming

Creating Typed DataSets For More Efficient Programming

  • Print
  • + Share This
Using Typed DataSets, you can make your programming efforts more efficient and precise, while at the same time providing type safety that normal DataSets lack. Rahul Sharma walks you through the process of creating a Typed DataSet.
Like this article? We recommend

Like this article? We recommend

This article aims to give you an introduction to the technique of creating rich and powerful DataSets with the help of C# to make your programming efforts more efficient and precise. At the same time, you can provide type safety for DataSets by using Typed DataSets, to avoid errors at runtime.

Tools and Technologies Used

We will be using the following tools and technologies to build our example:

  • Visual Studio.NET

  • Windows 2000

  • Visual C#

  • SQL Server 2000

This article assumes that you are already familiar with the concepts of ADO.NET DataSet.

Typed DataSets are not a set of .NET Framework classes like DataSets are. They are the classes generated by tools provided with .NET Framework, and they have complete DataSet functionality (methods, events, and properties) with some additional benefits.

Clearly, to have all the functionality of DataSets, Typed DataSets directly inherit from the DataSet classes. Some additional code generated by .NET Framework tools gives all the additional benefits of Typed DataSets. Furthermore, you can access table and columns by name instead of having to use collection-based methods with DataSets and using indexers until you reach the DataRow level. That involves a greater possibility that a table or column name will be misspelled, resulting in an error at runtime.

Aside from the improved readability of the code, a typed DataSet allows the Visual Studio.NET code editor to automatically complete lines while typing (using Intellisense functionality). Typed DataSets also provide access to values of the correct type at compile time. Thus, mismatch errors are reported at compile time and are not delayed to runtime. This is known as type-safe access to the DataSet—hence the name Typed DataSets.

  • + Share This
  • 🔖 Save To Your Account