adonet.jpg (1674 bytes)

Typed Data Set Objects

Many times programmers spend hours finding errors that turn out to be that the programmer typed “Cleint” instead of “Client”.  .NET allows use some flexibility here with database connections.

What we’d really like is a DataSet object that’s tailored to the particular data that we expect to receive from a specific operation. It would have table and column names already wired into it as hard-coded variables. It would allow Intellisense to show these names during programming so that we wouldn’t have to reach for the paper manual. And we wouldn’t have to worry about misspellings because the compiler would catch us if we somehow ignored
Intellisense and got a name wrong.  ADO.NET supports exactly such a feature through the typed
DataSet class. This is a custom class, derived from System.Data.DataSet that provides named member variables for each specific table, row, and column.

After populating a typed DataSet object, accessing it is easy given the type members. Instead of saying foo.Tables (“Authors”).Rows, I say foo.GetAuthors.Rows. It may not sound like much, but it removes a common source of errors (misspelling the string), and saves programmer time by allowing Intellisense support.