Yesterday while hanging at the pool with the kids I finished reading, Beginning C# 2008 Databases: From Novice to Professional.
I really enjoyed the book, finding it always good to go back and review the basics of ADO.NET with SQL Server. If I were just learning ADO.NET for the first-time, Beginning C# 2008 Databases is a solid introduction to the fundamentals of ADO.NET using C# and T-SQL. It goes into really good detail on the ADO.NET Connected Model: Connections, Commands, DataReaders, Transactions, etc. as well as sprinkles proven practices on recommended use of the connected model with regards to performance and maintainability. There is also a chapter covering the Disconnected Model: DataAdapters, DataTables, DataSets, DataViews, etc.
I thought one of the last chapters was especially good and useful to new ADO.NET Developers: Handling Exceptions. It showed the proper way to construct a Try / Catch / Finally Block around ADO.NET Code as well as how to catch exceptions and make sure database resources are properly closed and disposed. The chapter also discussed raising errors in SQL Server to better populate exceptions with useful error information.
There is some interesting sections on how to obtain the schema information about resultsets and table information that can be read from the DataReader. Although the need for such knowledge may not come up a lot, it helps one understand a bit how many of the Visual Designers in Visual Studio get database schema information.
If you are unfamiliar with SQL Server 2005 Specific features, there is some coverage of ROW_NUMBER, Comon Table Expressions, and the XML Support in SQL Server 2005. The authors also provide code examples of retrieving and inserting text and binary data into SQL Server.
At the end, there are a couple of introductory chapters on LINQ To SQL and ADO.NET Entity Framework to point you to where things are going, but they are just there as more of a segue to continued learning on data access.
The are two subjects that were not mentioned in the book that I think could / should have been covered in a beginning-style book:
Writing database agnostic code using DbProviderFactories, DbProviderFactory, etc
System.Transactions. There was no coverage of TransactionScope, etc.
I also would have liked the recommended proven-practices called out a bit more. They are there, which is cool, but I wish they were highlighted a bit more so one can easily go back through the text and refer to them.
Overall, I thought the ADO.NET and T-SQL Coverage in Beginning C# 2008 Databases was really good and easy-to-digest for someone just getting started.
by David Hayden
P.S. If you find yourself writing a lot of ADO.NET Code in your applications, you may want to look at the Enterprise Library Data Access Application Block or the LINQ To SQL API that helps you from having to write a lot of the ADO.NET plumbing code. Later you can look at Entity Client and Entity SQL in the ADO.NET Entity Framework that abstracts out the database schema. I actually mention a lot of this in a couple of upcoming presentations on Data Access Tips & Techniques.