Errata

Microsoft® ADO.NET 4 Step by Step

Errata for Microsoft® ADO.NET 4 Step by Step

The errata list is a list of errors and their corrections that were found after the product was released. If the error was corrected in a later version or reprint the date of the correction will be displayed in the column titled "Date Corrected".

The following errata were submitted by our customers and approved as valid errors by the author or editor.

Color key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted By Date submitted Date corrected
Printed
Page Code
C# sample code for Chapter 7

In the downloadable sample code for Chapter 7, in the C# version of the "Serialization" form's code, there is a bug near the end of the "ActGenerate_Click" event handler. In that routine, three lines from the bottom, is a line that sets the charArray variable to a new character array. The "- 1" at the end of this line should be removed. The line should read:

charArray = new Char[decoder.GetCharCount(holdBuffer.ToArray())];

Tim Patrick
 
Sep 04, 2013 
Printed
Page 293
First paragraph

Second line of first paragraph includes the non-word "andunlike." Change this word to "unlike."

Tim Patrick
 
Aug 14, 2013 
Printed
Page xxii
Step 4.

Missing "Click Open button" in instructions/paragraph.

Note from the Author or Editor:
In Step 4 on page xxii, after locating the "DB Script.sql" file in the Open dialog, you do need to click the dialog's Open button to load the file into SQL Server Management Studio.

Marco A. Abusleme  Mar 10, 2013 
Printed
Page 54
3

The CustomerAccounts_RowChanging event handler correctly sets the row error when the user enters an active account with a null date, however in the provided sample code the error state of the added row is never examined.

In AccountManager.cs function ActAdd_Click:

CustomerAccounts.Rows.Add(editRecord);
//The row level error isn't set until now, CustomerAccounts.HasErrors is now true but never checked.

CustomerAccounts.AcceptChanges();
addComplete = true;

Note from the Author or Editor:
The reader is correct. In order to demonstrate specific concepts in sample code as clearly as possible, many of the samples lack rigorous error handling logic. However, because this chapter deals specifically with data validation, more error management code of the type indicated by the reader should be included.

Anonymous  Jan 19, 2013 
Printed
Page 38
Defining Row Values Section

There is a snippet of code that doesn't work in the IDE.
oneRow.Item["ID"] = 123; //this throws the following error:
'System.Data.DataRow' does not contain a definition for 'Item' and no extension method 'Item' accepting a first argument of type 'System.Data.DataRow' could be found (are you missing a using directive or an assembly reference?)

The corrected code follows on page 39 "(oneRow["ID"] = 123;)" but after typing it into VS and getting the error, I didn't continue on, and went troubleshooting. The test should omit the block between paragraphs 1 and 2 to prevent confusion.

Note from the Author or Editor:
Your comments refer to the C# sample code. You are correct that the "Item" property name should be excluded from the C# portion of the sample shown at the bottom of page 38.

Jahan Abdul  Jul 19, 2012 
Printed
Page 306
1st paragraph of new section called "Writing Queries with LINQ to DataSet"

In the book on the page and paragraph mentioned above there is written: "The first step involves converting a data table to its enumerable equivalent using the and, which can be applied to any DataTable instance." followed by an example of the AsEnumerable extension method.
I think that "and" in the above sentence should be replaced by AsEnumerable, since and is nowhere mentioned in the code example.

Note from the Author or Editor:
In the paragraph you mentioned, replace the italicized word "and" with "AsEnumerable extension method."

Peter Demeester  Mar 11, 2012 
Printed, PDF, , Other Digital Version
Page 391
last column, middle

The index term "in Windows Presentation Foundation (WTF)" has a typo in the parentheses and should read (WPF)

Note from the Author or Editor:
It appears in the "data binding" index entry on page 391, and is kind of hilarious. Thanks for catching the typo.

Kristen  Dec 07, 2011 
Printed
Page 92
Supplied code is wrong

The example code does not open if the user's PC is not using American culture - the data for the app provides dates like "7/23/1819" which in most of the world is not a valid date.
In the supplied code, Aggregate.cs, line 224 should be:
if (lineFields[3].Length > 0) oneRow["Statehood"] = DateTime.Parse(lineFields[3], new CultureInfo("en-US"));

Note from the Author or Editor:
The reader is correct. Another solution is to modify the sample data so that it contains location-agnostic date content.

Anonymous  Apr 24, 2011 
Printed
Page 147
Step 6

Using SQLServer 2008 (non-Express) as the database, the line:

ActiveStateID = (long)(int)stateReader["ID"];

gives and Invalid Cast exception during runtime after adding a record.

Removing the (int) and just having (long)stateReader["ID"] fixes the problem.

Note from the Author or Editor:
This is a typo in the C# version of the program. The reader is correct that "(int)" should be removed so that only "(long)" remains. The correction should be made in the "Completed Example" for Chapter 9 in the downloadable code. The Visual Basic of the code is already correct.

Chris Brown  Mar 30, 2011 
PDF
Page 278
Last line of C# code sample

return pieces(position - 1);
should be:
return pieces[position - 1];

Note from the Author or Editor:
This typo appears at the bottom of the page, on the last code line of the C# sample.

Vizer Tibor  Jan 10, 2011 
Printed
Page 206
item 4

I was unable to get the distributed transaction to work.

I think a @ToAccount reference should be changed to a @FromAccount reference in:

// ----- Prepare and perform the withdrawal.
sqlText = @"UPDATE bankAccount SET Balance = Balance - @ToTransfer WHERE AccountNumber = @FromAccount";
withdrawal = new SqlCommand(sqlText, linkToDB, envelope);
withdrawal.Parameters.AddWithValue("@ToTransfer", toTransfer);
if (OptFromChecking.Checked)
withdrawal.Parameters.AddWithValue("@FromAccount", CheckingAccountID);
else
withdrawal.Parameters.AddWithValue("@FromAccount", SavingsAccountID);

That solved the error but the money still did not transfer.

Of course, this could be a typo on my part but I feel it is worth investigating.

Thanks,
Bob Reding

Note from the Author or Editor:
The book is correct, but the sample code for Chapter 12 is in error. In the C# sample code for Chapter 12, the AccountTransfer.cs file, the TransferDistributed() routine, change the following line:

withdrawal.Parameters.AddWithValue("@ToAccount", CheckingAccountID);

to this code instead:

withdrawal.Parameters.AddWithValue("@FromAccount", SavingsAccountID);

The Visual Basic version of the sample application is already correct. An updated copy of the sample code will be placed on the book's web site. If you are using the updated version, you will not need to make this change.

Bob Reding  Jan 02, 2011 
Printed, PDF
Page 21
Middle

The mentioned code samples link is wrong and on the webpage, the link to http://examples.oreilly.com/0790145300034/ADO.NET_4_SBS_Examples.zip is wrong, too ...

Can you please provide the correct link?

Thank you very much.
Daniel Bloch

Note from the Author or Editor:
The link has been fixed. On the book's web page, the "Download Example Code" link appears on the left side of the page, just below the book's image.

Daniel Bloch  Nov 09, 2010