Home > Guides > Programming > .NET and Windows Programming

Toggle Open Guide Table of ContentsGuide Contents

Close Table of ContentsGuide Contents

Close Table of Contents

Working with Typed DataSets

Last updated Aug 26, 2004.

A typed dataset is a class that derives from DataSet and provides type-safe access to tables and columns. Since a typed dataset derives from the ADO.NET DataSet class, it inherits all of the methods, properties, and events of DataSet. The primary benefit of the typed dataset is that it allows you to access tables and columns by name rather than through collection-based methods. For example, using plain DataSet objects, the code to obtain the LastName column from a record in the Employees table would look like this:

[C#]

string lastName = dsEmployees1.Tables["Employees"].Rows[0]["LastName"].ToString();

[Visual Basic]

Dim lastName As String = dsEmployees1.Tables("Employees").Rows(0)("LastName").ToString()

That's assuming that dsEmployees1 is a DataSet object that had previously been filled with the data from the Employees table.

A typed dataset gives you access to the same information, but in a type-safe manner. For example, if dsEmployees1 were a typed dataset, then the code to obtain the LastName column from a record would look like this:

[C#]

string lastName = dsEmployees1.Employees[0].LastName;

[Visual Basic]

Dim lastName As String = dsEmployees1.Employees(0).LastName

Discussions

Copies of the array?
Posted Dec 23, 2008 03:40 PM by luige21
1 Replies
Hi
Posted Dec 5, 2008 05:10 AM by ajay2000bhushan
2 Replies
You have no clue.
Posted Jun 10, 2008 03:28 PM by theinternetmaster
1 Replies

Make a New Comment

You must log in in order to post a comment.

Related Resources

Jim Mischel"Highly unlikely" does not mean "impossible"
By Jim MischelJuly 18, 2009 No Comments

One of my programs crashed the other day in a very unexpected place.  A call to System.Threading.ConcurrentQueue.TryDequeue (from the Parallel Extensions to .NET) resulted in an OverflowException being thrown.  Investigation revealed a pretty serious bug in the System.Random constructor.

It's Here; Put Away Your Pre-Conceptions on What an OS Must Be: Part II
By John TraenkenschuhMay 24, 2009 No Comments

In the last blog in this series, Traenk relates his first experiences with computers and with coding.  But now, some years have passed. . .

It's Here; Put Away Your Pre-Conceptions on What an OS Must Be: Part I
By John TraenkenschuhMay 24, 2009 No Comments

Traenk relates his past experience with Operating Systems that goes back 25 years, ok, more than that but he ain't tellin'

See More Blogs

Informit Network