Mike Hildner
Jul 14th, 2004, 01:23 PM
Need some help understanding why the following code does not throw an exception.
// Update the table.
DataTable dtUnitsCurrentOfficers = dtc["Units_Current_Officers"];
newRow = dtUnitsCurrentOfficers.NewRow(); // No exception here
newRow["Unit_Guid"] = unitGuid;
newRow["Officer_Guid"] = officerGuid;
dtUnitsCurrentOfficers.Rows.Add(newRow);
return true;
dtc is a DataTableCollection, and the table "Units_Current_Officers" does not exist in it. I would think that the next line of code, where I try to get a new row, would throw an exception because at this point dtUnitsCurrentOfficers is an undefined value.
To my dismay, no error, and the app continues, even though the rest of the code in that method does not get executed.
Any help appreciated,
Mike
// Update the table.
DataTable dtUnitsCurrentOfficers = dtc["Units_Current_Officers"];
newRow = dtUnitsCurrentOfficers.NewRow(); // No exception here
newRow["Unit_Guid"] = unitGuid;
newRow["Officer_Guid"] = officerGuid;
dtUnitsCurrentOfficers.Rows.Add(newRow);
return true;
dtc is a DataTableCollection, and the table "Units_Current_Officers" does not exist in it. I would think that the next line of code, where I try to get a new row, would throw an exception because at this point dtUnitsCurrentOfficers is an undefined value.
To my dismay, no error, and the app continues, even though the rest of the code in that method does not get executed.
Any help appreciated,
Mike