Groups | Blog | Home
all groups > dotnet windows forms > november 2005 >

dotnet windows forms : Can't remove expression column!!! So I can't update data!!! Help


dbuchanan
11/30/2005 4:14:12 AM
Hello,

[quoted text, click to view]

~ Bart, are you there?

I added an expression column to the dataset to display the value in a
related lookup table.

However when events on my form would normally update the dataset I
receive the following error;
------------------
Exception Message:
Cannot change ReadOnly property for the expression column.
------------------

Therefore I added code to remove the expression column before the
update and then recreate the expression column after the update;
\\
'Remove expression column
_dataset1.Tables("tbl010Job").Columns.Remove("SysVoltage")

_bmb.EndCurrentEdit()
Call UpdateSource1()

'Restore expression column
'Add column(s) to the dataset to display a field from the
relation
_dataset1.Tables("tbl010Job").Columns.Add("SysVoltage",
GetType(String), "Parent(FK_tbl010Job_lkp104Voltage).Voltage")
//

This does not resolve the problem I get the following error;
----------------------------------------------
An unhandled exception of type 'System.Data.DuplicateNameException'
occurred in system.data.dll

Additional information: A column named 'SysVoltage' already belongs to
this DataTable.
-----------------------------------------------

So removing an expression column does NOT remove it! What is the
solution to this dilemma? How do I get around this problem?

dbuchanan
dbuchanan
11/30/2005 9:12:23 AM
Hi Bart,

I found the problem.

I am using multiple inherited forms which makes it a little more
difficult to track this.

Do you know if this bug that requires removing and readding expression
columns is fixed in vb2005?

Thank you,
dbuchanan
Bart Mermuys
11/30/2005 3:49:15 PM
Hi,

[quoted text, click to view]

Yes :-)

[quoted text, click to view]

Yes that seems right. So i don't know why you have this error, i did test
this at the time i posted the message and i did a quick test now and it
worked.

The error you have seems to suggest that the expression column wasn't
removed or already been re-added, can you double check everything ? Are you
sure UpdateSource1() doesn't re-add it ?

HTH,
Greetings



[quoted text, click to view]

Bart Mermuys
12/1/2005 10:43:57 AM
Hi,

[quoted text, click to view]

Yep, can imagine that.

[quoted text, click to view]

Nope, haven't tried it yet.

Greetings

[quoted text, click to view]

AddThis Social Bookmark Button