C
CleverMindworks
Hi everyone,
I have a C# application that is using SqlDataAdapter and
SqlCommandBuilder for performing updates to a single table in a SQL 7
database. For the most part, everything works just fine. I recently
hit a very strange issue, where it seems that not all columns are being
updated against the data source.
Scenario:
A DataSet object contains rows (1600) of data with the majority of
rows containing changes. (Determined by careful debugging and observing
the 'Current' and 'Original' values for the rows with state ==
Modified) For a changed row, for instance, there are columns
"AccountID", "Address1", "Country", "ExtraField1", etc.
Observations:
Digging into the SqlDataAdapter and looking at the UpdateCommand, I
can clearly see an update statement, in correct syntax, with 65
parameters. (As the Update command that is built contains the hints for
optimistic concurrency, so a bunch of extra 'where @pXX <> null ...'.
The key here is that all columns are listed in the statement. Using my
previous example, "Address1", "Country", "ExtraField1" are all listed
in the update clause.
Performing a SQL trace (filtering on the Text containing the PK), I
witness something rather disturbing. The statement looks like:
"UPDATE Accounts SET AccountID = @p1, ExtraField1 = @p2 WHERE ..."
It's quite subtle. This is the update statement that corresponds to
the row I was introspecting. There are a total of 11 updated columns
in the DataSet, yet, the UPDATE statement sent to the database contains
only the PK column and the last 6 columns. (Out of a total of 15).
==
So, if anyone knows how the DataAdapter builds the actual update
statement, perhaps you could lend me a hand. I'm suspecting a bug in
the DataAdapter that may be mitigated by the data, or perhaps the
schema info. The DataSet contains full schema info, including primary
key.
I'm thinking that manually writing the Update statement may solve the
issue, but I'm quite fond of letting the CommandBuilder do the work.
:0)
Any advice is greatly appreciated.
Regards,
-Sean
I have a C# application that is using SqlDataAdapter and
SqlCommandBuilder for performing updates to a single table in a SQL 7
database. For the most part, everything works just fine. I recently
hit a very strange issue, where it seems that not all columns are being
updated against the data source.
Scenario:
A DataSet object contains rows (1600) of data with the majority of
rows containing changes. (Determined by careful debugging and observing
the 'Current' and 'Original' values for the rows with state ==
Modified) For a changed row, for instance, there are columns
"AccountID", "Address1", "Country", "ExtraField1", etc.
Observations:
Digging into the SqlDataAdapter and looking at the UpdateCommand, I
can clearly see an update statement, in correct syntax, with 65
parameters. (As the Update command that is built contains the hints for
optimistic concurrency, so a bunch of extra 'where @pXX <> null ...'.
The key here is that all columns are listed in the statement. Using my
previous example, "Address1", "Country", "ExtraField1" are all listed
in the update clause.
Performing a SQL trace (filtering on the Text containing the PK), I
witness something rather disturbing. The statement looks like:
"UPDATE Accounts SET AccountID = @p1, ExtraField1 = @p2 WHERE ..."
It's quite subtle. This is the update statement that corresponds to
the row I was introspecting. There are a total of 11 updated columns
in the DataSet, yet, the UPDATE statement sent to the database contains
only the PK column and the last 6 columns. (Out of a total of 15).
==
So, if anyone knows how the DataAdapter builds the actual update
statement, perhaps you could lend me a hand. I'm suspecting a bug in
the DataAdapter that may be mitigated by the data, or perhaps the
schema info. The DataSet contains full schema info, including primary
key.
I'm thinking that manually writing the Update statement may solve the
issue, but I'm quite fond of letting the CommandBuilder do the work.
:0)
Any advice is greatly appreciated.
Regards,
-Sean