DataAdapter.Update calling Insert Command with DbNull values

G

Guest

This is so completely baffling me that I'd throw it out for general
consumption. I have an enterprise application with dozens of DataAdapters.
All are based off a common DataAdapterBase class I engineered to streamline
and standardize how typical data access works across the solution. All work
fine, except for one that I've recently modified - I changed the field names
of the underlying table (and therefore the parameters of the stored
procedures, the fields of the typed DataSet, etc.) Now, when I call
DataAdapter.Update, it fails on an Insert. Specifically, it doesn't pass any
values from the DataRow to the Parameters collection. They're all DbNull.
Updates work fine (there is no mechanism within the UI to Delete rows), as do
Inserts to other tables via other DataAdapters. The Parameters collections
of both the Insert and Update Commands are populated via my common base class
by the same mechanism. I've examined closely several times the DataAdapter,
Command, DataRow, DataSet, etc, objects involved and can't find any
difference between the Insert that's failing and the Update that works (or
any other Insert that I've inspected). There just seems to be no cause. Any
thoughts out there on this one?
 
G

Guest

I did check that, and it was not the problem. The original cause was
actually a ComboBox whose DataSource was the DataSet. The Insert was
triggering the control's SelectedValueChanged event, which was, in turn,
modifying the DataRow. Since it was an event procedure (in another Form, no
less), I never stepped through it in break mode and had no idea it was even
firing. I've since replaced the ComboBox with a third-party control that
distinguishes changes to the DataSource from user-driven changes to the
selected item.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top