For a technical book to qualify as a “good book,” it has to meet my four primary criteria: It must be accurate, well organized, easy to read, and useful as a reference. Based on these criteria, it’s hard for me to call Apress’s Database Programming with C# a good book, because it falls short in the easy-to-read and well-organized categories. Still, I can’t quite bring myself to call it a bad book: It is an outstanding technical reference to ADO.NET from the point of view of a C# programmer.

Database Programming with C#

Carsten Thomsen
667 pages
ISBN: 1590590104
April 9, 2002
Cover price: $54.95
Highs: Solid introduction to ADO.NET development with lots of C# sample code. Great reference value.
Lows: Organization problems in parts of the book, glosses over transactions.

Technical value is the high point
Viewed solely as a reference manual for the .NET platform’s ADO.NET data access libraries, this book is very good. It makes no assumptions about the reader’s skill level, providing quick introductions to C# and database design in the first two chapters. From there, the author moves on to cover the ADO.NET classes and later devotes entire chapters to exception handling, hierarchical databases, message queues, and data-bound controls. The only missing piece here is transactions, which are touched on in the early chapters and then mostly forgotten. As a special bonus to SQL Server developers, there’s an appendix on the XML support built into SQL Server 2000.

You’ll find plenty of code examples in the book, all in C# as you’d expect. The sample code is lightly commented and easy to follow because most of it shares a single theme, the construction of a sample C# application called UserMan—an Active Directory user administration app, which you’ll eventually complete in the final chapter. Throughout, the author, Carsten Thomsen, does an excellent job of providing usage tips and pointing out common errors while discussing sample code. Unfortunately, there’s no code CD included with the book, which is a little disturbing considering this title has a list price of over $50. You can, however, download the source from Apress, which takes some of the sting away.

Chapter 2, “Database Programming,” is a particularly good starting spot for neophytes. You’ll get the run down on important aspects of database design, like normalization, and contrasting hierarchical and relational databases in an efficient, no-nonsense manner. A good understanding of these concepts is fundamental to understanding ADO.NET.

More advanced readers will likely start in Chapter 3, “Presenting ADO.NET,” which is divided into two subchapters. Chapter 3A, “The Connected Layer,” concentrates on the database system-dependent parts of ADO.NET: data providers, command classes, and connection classes. Chapter 3B, “The Disconnected Layer,” covers the objects you’ll actually use to manipulate the data from a database, which are essentially the same regardless of the data provider used; DataSet, DataTable, DataView, and others are all examined in turn.

Warning: Big, ugly tables ahead
Unfortunately, things get a little rough here. Chapters 3A and 3B are mostly dominated by large tables listing method and property information for the various classes the author discusses. The tables themselves are poorly formatted and stretch on for page after page in text that’s only distinguishable from the rest of the book by horizontal divider lines. While the information is handy, it’s nothing you couldn’t get on your own from MSDN.

Providing information that’s largely redundant is a habit that continues throughout the rest of the book. Certainly, some description of class members is needed before you can talk about a class, and a table is probably the best method of displaying this information. But, exhaustive member listings like what you’ll find here are best left to documentation, and the huge, ugly, headache-inducing tables used for the listings create more information digestion problems than they solve. It’s particularly troubling to see this sort of thing in a book from Apress, a publisher that has built itself around the idea that a technical book should be more than just “rehashed documentation.”

Plagued by organization problems
While formatting is probably not the fault of the author, Thomsen should take part of the blame for the real disappointing aspect of Database Programming with C#, which is poor organization. I hate to sound like I’m judging an entire book by the contents of one chapter, but Chapter 3 is a prime example of the chapter organization problems that plague this book.

ADO.NET has three separate connection classes, which have significant differences in their implementation and the features they support. Which one you should use depends largely on the database backend and ADO.NET provider you plan to use for your app. Thomsen tries gamely to compare and contrast all three different types of connections, even though he primarily uses the SQL Server connection variants throughout the book. I’d have no problem with this if he didn’t try to talk about them all at the same time. What results is a confusing mess of contradictory statements, and lots of “but if you’re using this connection” exceptions. Why the OLE-DB and ODBC connections weren’t covered separately, preferably in an appendix, is a mystery to me.

Still…it’s not bad
Enough prattling on about gratuitous use of tables—despite my negativity, the book isn’t horrible. I’d take it over an “In 21 Days” title any day of the week, primarily because it’s such a good database development handbook—although calling any two-inch-thick tome a handbook might be a mistake. If you’re looking for a C#-specific ADO.NET book, I’d suggest this: Give it a long look at your local bookstore, and decide whether or not you can stand the format. Then, pick up a bottle of aspirin on your way home.