views:

153

answers:

2

I have a typed dataset, and where I call TableAdapter.Update(DataRow), the SQL executed includes an update of the primary key column of the database.

Unfortunately, when this code runs on a replicated database, the PK column has the rowguid property set, and I get the following error:

System.Data.SqlClient.SqlException: Updating columns with the rowguidcol property is not allowed. The transaction ended in the trigger. The batch has been aborted. at System.Data.Common.DbDataAdapter.UpdatedRowStatusErrors(RowUpdatedEventArgs rowUpdatedEvent, BatchCommandInfo[] batchCommands, Int32 commandCount) at System.Data.Common.DbDataA...

How do I prevent the tableadapter from updating this column (the value is the same)?

+1  A: 

You can manually edit the SQL created for the update command in the DataSet designer Just click on the adapter and find the UpdateCommand. Is there a reason that you're updating the primary key? If not (and you shouldn't be, if at all possible), then you should remove that from the command.

Adam Robinson
I totally *don't want* it to update the PK - that's the auto-generated SQL, not me. You make a good point about editing it though. Only trouble is that the edit will be lost if/when the class is regenerated through the designer <sigh>.
Neil Barnwell
A: 

If your column is actually marked as the primary key in the typed DataSet the auto generated updated statement should not be trying to update it. I would look at the designer and double check that it is actually the primary key.

Gratzy
Yes = I've checked that and it looks fine. I might try regenerating it from scratch and see if it makes any difference.
Neil Barnwell