There is no Original data to access when updating a DataTable with computed columns

A

Andrea Caldarone

Hi all,

this was driving me crazy! I've a datatable its related sqlDataAdapter, if I
call the .Update method of the adapter everything is ok, but if I add a
compute column to the DataTable (a columns computed via a DataRelation) I
receive the "There is no Original data to access"
 
W

W.G. Ryan [MVP]

Andrea: Are you saying that as long as you don't have any expression
columns, all is well, but if you add one, then the Update fails? If so, is
the code being regenerated or something? It sounds like a columnmapping is
being added somewhere
 
A

Andrea Caldarone

W.G. Ryan said:
Andrea: Are you saying that as long as you don't have any expression
columns, all is well, but if you add one, then the Update fails? If
so, is the code being regenerated or something? It sounds like a
columnmapping is being added somewhere

I try to go deeper:

I have a datatable with is sqlDataAdapter, and always that works fine. If I
add a computed datacolumn that have the "Child(relation_name)"clause into
its expression property, the .Update of the sqlDataAdapter fails throwing
the execption "Tehere is no Original data to access", if I simply remove
that column, the Update works.
 
P

Petar Repac

Do you use CommandBuilder ?

Try to set a breakpoint on SqlAdapter.Update and inspect
Insert, Update and Delete commands for SqlParameters.
Seems like there is a parameter that is "bound" to your calculated
column and to its "original" value.

That parameter should not be there.
 
A

Andrea Caldarone

Petar said:
Do you use CommandBuilder ?

No! For Christ's sake
Try to set a breakpoint on SqlAdapter.Update and inspect
Insert, Update and Delete commands for SqlParameters.
Seems like there is a parameter that is "bound" to your calculated
column and to its "original" value.

That parameter should not be there.

There is no parameter "bound" to my computed column, I don't pass any
parameter (doh!) for the computed column
 
C

Cor Ligthert [MVP]

Andrea,

May I assume that you have created the update command yourself.

A datarow holds two versions of items *as they are read from a database* the
current data and the original data. The original data is used for
concurrency checking. The working about this is slightly different in
version 1.x and 2.0

Can it be related to the above text.

Cor
 

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