By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,384 Members | 714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,384 IT Pros & Developers. It's quick & easy.

"Cannot change ReadOnly property of the expression column"

P: n/a
Ok. I have a dataset that has multiple tables in it. In one of the child
tables, I have a column that I added to the DataSet (Not in the
DataSource). This column does not need to be stored in the data on the
datasource. It simply gets the first name and last name of an instructor
and displays it in the grid. I have two major problems.... One, it
doesn't display in the column until the row is saved, (Even after
calling a refresh on the grid) and two, I am getting a Cannot change
ReadOnly property of the expression column error message when I try to
update the datasource. I found a lot of confusing information that dealt
with the column updating the datasource, etc etc. The column is in none
of the commands attached to the data adapters.

For the column refresh problem, I added code to manually fill in that
field when leaving a previous column and that seemed to work, however,
it doesn't always show when doing a refresh. I have to navigate back to
that column in order to see it.

Any ideas on either problem?
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
How did you add the column to the dataset? You added it to the Table? Can
you post some simplified code that shows the problem?

Chris

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:bb**************@newssvr19.news.prodigy.com.. .
Ok. I have a dataset that has multiple tables in it. In one of the child
tables, I have a column that I added to the DataSet (Not in the
DataSource). This column does not need to be stored in the data on the
datasource. It simply gets the first name and last name of an instructor
and displays it in the grid. I have two major problems.... One, it doesn't
display in the column until the row is saved, (Even after calling a
refresh on the grid) and two, I am getting a Cannot change ReadOnly
property of the expression column error message when I try to update the
datasource. I found a lot of confusing information that dealt with the
column updating the datasource, etc etc. The column is in none of the
commands attached to the data adapters.

For the column refresh problem, I added code to manually fill in that
field when leaving a previous column and that seemed to work, however, it
doesn't always show when doing a refresh. I have to navigate back to that
column in order to see it.

Any ideas on either problem?
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #2

P: n/a
I just added it to the Dataset Schema and then set the expression in the
new procedure of the form...

CoursesDS1.InstClasses.FullNameColumn.Expression =
"Parent(InstructorsInstClasses).First_Name + ' ' +
Parent(InstructorsInstClasses).Last_Name"

Thats the expression...

If that is the only line of code in there, and I don't manually set the
value, it still does not work.. I still get the same message. Should I
remove that column from the schema and manually create the column and
add it to the table?? I think I will try that while waiting for other
suggestions.

Aaron

Chris, Master of All Things Insignificant wrote:
How did you add the column to the dataset? You added it to the Table? Can
you post some simplified code that shows the problem?

Chris

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:bb**************@newssvr19.news.prodigy.com.. .
Ok. I have a dataset that has multiple tables in it. In one of the child
tables, I have a column that I added to the DataSet (Not in the
DataSource). This column does not need to be stored in the data on the
datasource. It simply gets the first name and last name of an instructor
and displays it in the grid. I have two major problems.... One, it doesn't
display in the column until the row is saved, (Even after calling a
refresh on the grid) and two, I am getting a Cannot change ReadOnly
property of the expression column error message when I try to update the
datasource. I found a lot of confusing information that dealt with the
column updating the datasource, etc etc. The column is in none of the
commands attached to the data adapters.

For the column refresh problem, I added code to manually fill in that
field when leaving a previous column and that seemed to work, however, it
doesn't always show when doing a refresh. I have to navigate back to that
column in order to see it.

Any ideas on either problem?
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.


--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #3

P: n/a
I'm still getting this error, does anyone have any more ideas? I removed
the field from the schema and manually add it and I still get the error
message. The record actually saves, but this error just pops up.. If
there a way to turn error checking off for certain fields? Is it just a
property I am not setting?

Aaron Smith wrote:
I just added it to the Dataset Schema and then set the expression in the
new procedure of the form...

CoursesDS1.InstClasses.FullNameColumn.Expression =
"Parent(InstructorsInstClasses).First_Name + ' ' +
Parent(InstructorsInstClasses).Last_Name"

Thats the expression...

If that is the only line of code in there, and I don't manually set the
value, it still does not work.. I still get the same message. Should I
remove that column from the schema and manually create the column and
add it to the table?? I think I will try that while waiting for other
suggestions.

Aaron

Chris, Master of All Things Insignificant wrote:
How did you add the column to the dataset? You added it to the
Table? Can you post some simplified code that shows the problem?

Chris

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:bb**************@newssvr19.news.prodigy.com.. .
Ok. I have a dataset that has multiple tables in it. In one of the
child tables, I have a column that I added to the DataSet (Not in the
DataSource). This column does not need to be stored in the data on
the datasource. It simply gets the first name and last name of an
instructor and displays it in the grid. I have two major problems....
One, it doesn't display in the column until the row is saved, (Even
after calling a refresh on the grid) and two, I am getting a Cannot
change ReadOnly property of the expression column error message when
I try to update the datasource. I found a lot of confusing
information that dealt with the column updating the datasource, etc
etc. The column is in none of the commands attached to the data
adapters.

For the column refresh problem, I added code to manually fill in that
field when leaving a previous column and that seemed to work,
however, it doesn't always show when doing a refresh. I have to
navigate back to that column in order to see it.

Any ideas on either problem?
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #4

P: n/a
I fixed this problem. The solution is quite simple. Whenever you call
Update on the dataadapter, just remove the expression and then add it
back after the update is finished:

Dim dc As DataColumn = DataSet.Table.Columns.Item("ExpCol")
Dim exp As String = dc.Expression
dc.Expression = ""
Try
DataAdapter.Update(DataSet, "Table")
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message(), "Error")
Finally
dc.Expression = exp
End Try

I tried to just remove the whole column, then add it back in, but for
some reason I was getting an error message that the column wasn't a
datacolumn or datarelation, so I simplified...

Aaron Smith wrote:
I'm still getting this error, does anyone have any more ideas? I removed
the field from the schema and manually add it and I still get the error
message. The record actually saves, but this error just pops up.. If
there a way to turn error checking off for certain fields? Is it just a
property I am not setting?

Aaron Smith wrote:
I just added it to the Dataset Schema and then set the expression in
the new procedure of the form...

CoursesDS1.InstClasses.FullNameColumn.Expression =
"Parent(InstructorsInstClasses).First_Name + ' ' +
Parent(InstructorsInstClasses).Last_Name"

Thats the expression...

If that is the only line of code in there, and I don't manually set
the value, it still does not work.. I still get the same message.
Should I remove that column from the schema and manually create the
column and add it to the table?? I think I will try that while waiting
for other suggestions.

Aaron

Chris, Master of All Things Insignificant wrote:
How did you add the column to the dataset? You added it to the
Table? Can you post some simplified code that shows the problem?

Chris

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:bb**************@newssvr19.news.prodigy.com.. .

Ok. I have a dataset that has multiple tables in it. In one of the
child tables, I have a column that I added to the DataSet (Not in
the DataSource). This column does not need to be stored in the data
on the datasource. It simply gets the first name and last name of an
instructor and displays it in the grid. I have two major
problems.... One, it doesn't display in the column until the row is
saved, (Even after calling a refresh on the grid) and two, I am
getting a Cannot change ReadOnly property of the expression column
error message when I try to update the datasource. I found a lot of
confusing information that dealt with the column updating the
datasource, etc etc. The column is in none of the commands attached
to the data adapters.

For the column refresh problem, I added code to manually fill in
that field when leaving a previous column and that seemed to work,
however, it doesn't always show when doing a refresh. I have to
navigate back to that column in order to see it.

Any ideas on either problem?
Aaron
--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.




--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.
Nov 21 '05 #5

P: n/a
I was running into the same problem and, based on wht I learned here, decided
to catch and ignore the exception.

Alternative to manually accepting changes at the table level would be to
accept all changes in the dataset at the end of the updates.

Carl

Here is the code snippet:
Try
Me.sdaOrders.Update(inDS.Orders.Select("", "", _
DataViewRowState.Added Or
DataViewRowState.ModifiedCurrent))
Catch RO_exception As Data.ReadOnlyException
' do nothing, need to catch it for the expression column
' DO NOT Accept changes here, more changes to be saved later!
End Try
' can add, change, and delete because no subordinate tables
Me.sdaOrderPayments.Update(inDS.OrderPayments)

' only add or modify, can't delete because there are subordinate
tables
Me.sdaOrderDetails.Update(inDS.OrderDetails.Select ("", "", _
DataViewRowState.Added Or DataViewRowState.ModifiedCurrent))
' can add, change, and delete because no subordinate tables
Me.sdaOrderMiscCharges.Update(inDS.OrderDetailMisc Charges)
' only add or modify, can't delete because there are subordinate
tables

Me.sdaOrderDetailComponents.Update(inDS.OrderDetai lComponents.Select("", "", _
DataViewRowState.Added Or DataViewRowState.ModifiedCurrent))
' can add, change, and delete because no subordinate tables

Me.sdaOrderDetailComponentSpeficiations.Update(inD S.OrderDetailComponentSpecifications)

' now pick up the deletes, from the bottom up
Me.sdaOrderDetailComponents.Update(inDS.OrderDetai lComponents)
Me.sdaOrderDetails.Update(inDS.OrderDetails)
Try
Me.sdaOrders.Update(inDS.Orders)
Catch RO_exception As Data.ReadOnlyException
' accept changes manually and continue
inDS.Orders.AcceptChanges()
End Try

"Aaron Smith" wrote:
I fixed this problem. The solution is quite simple. Whenever you call
Update on the dataadapter, just remove the expression and then add it
back after the update is finished:

Dim dc As DataColumn = DataSet.Table.Columns.Item("ExpCol")
Dim exp As String = dc.Expression
dc.Expression = ""
Try
DataAdapter.Update(DataSet, "Table")
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message(), "Error")
Finally
dc.Expression = exp
End Try

I tried to just remove the whole column, then add it back in, but for
some reason I was getting an error message that the column wasn't a
datacolumn or datarelation, so I simplified...

Aaron Smith wrote:
I'm still getting this error, does anyone have any more ideas? I removed
the field from the schema and manually add it and I still get the error
message. The record actually saves, but this error just pops up.. If
there a way to turn error checking off for certain fields? Is it just a
property I am not setting?

Aaron Smith wrote:
I just added it to the Dataset Schema and then set the expression in
the new procedure of the form...

CoursesDS1.InstClasses.FullNameColumn.Expression =
"Parent(InstructorsInstClasses).First_Name + ' ' +
Parent(InstructorsInstClasses).Last_Name"

Thats the expression...

If that is the only line of code in there, and I don't manually set
the value, it still does not work.. I still get the same message.
Should I remove that column from the schema and manually create the
column and add it to the table?? I think I will try that while waiting
for other suggestions.

Aaron

Chris, Master of All Things Insignificant wrote:

How did you add the column to the dataset? You added it to the
Table? Can you post some simplified code that shows the problem?

Chris

"Aaron Smith" <th**********@smithcentral.net> wrote in message
news:bb**************@newssvr19.news.prodigy.com.. .

> Ok. I have a dataset that has multiple tables in it. In one of the
> child tables, I have a column that I added to the DataSet (Not in
> the DataSource). This column does not need to be stored in the data
> on the datasource. It simply gets the first name and last name of an
> instructor and displays it in the grid. I have two major
> problems.... One, it doesn't display in the column until the row is
> saved, (Even after calling a refresh on the grid) and two, I am
> getting a Cannot change ReadOnly property of the expression column
> error message when I try to update the datasource. I found a lot of
> confusing information that dealt with the column updating the
> datasource, etc etc. The column is in none of the commands attached
> to the data adapters.
>
> For the column refresh problem, I added code to manually fill in
> that field when leaving a previous column and that seemed to work,
> however, it doesn't always show when doing a refresh. I have to
> navigate back to that column in order to see it.
>
> Any ideas on either problem?
> Aaron
> --
> ---
> Aaron Smith
> Remove -1- to E-Mail me. Spam Sucks.



--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #6

P: n/a
OK, well, that solution wasn't quite as solid as I thought yesterday. I was
just hiding the problem. After more research apparently this is a known bug
since 2002 although I can find no reference to it when searching the MS KB.
There is a nice little writeup on it with workarounds at www.falafel.com/flogs

I chose to drop the expression columns, do the update, and restore them.
Simply setting the expression to empty or Nothing raised an "instance of
object not set" exception. Still needs more testing but it appears to get
around the problem. Since I have a separate data access layer I do it at
that level avoiding the problems (I think!) with dropping the columns and
databinding.

Carl

Here is a simple code snippet:

' save expression columns and delete them out so updates will go
through
Dim dcLastNameFirstExp As DataColumn =
inDS.Customer.Columns("LastNameFirst")
Dim dcCityStateZipExp As DataColumn =
inDS.Customer.Columns("CityStateZip")
inDS.Customer.Columns.Remove("LastNameFirst")
inDS.Customer.Columns.Remove("CityStateZip")

' save customer changes and additions
Me.sdaCustomer.Update(inDS.Customer.Select("", "", _
DataViewRowState.Added Or DataViewRowState.ModifiedCurrent))
' save all phone number changes, including deletes
Me.sdaPhoneNumber.Update(inDS.CustomerPhoneNumber)
' process customer deletes
Me.sdaCustomer.Update(inDS.Customer)
"clorentson" wrote:
I was running into the same problem and, based on wht I learned here, decided
to catch and ignore the exception.

Alternative to manually accepting changes at the table level would be to
accept all changes in the dataset at the end of the updates.

Carl

Here is the code snippet:
Try
Me.sdaOrders.Update(inDS.Orders.Select("", "", _
DataViewRowState.Added Or
DataViewRowState.ModifiedCurrent))
Catch RO_exception As Data.ReadOnlyException
' do nothing, need to catch it for the expression column
' DO NOT Accept changes here, more changes to be saved later!
End Try
' can add, change, and delete because no subordinate tables
Me.sdaOrderPayments.Update(inDS.OrderPayments)

' only add or modify, can't delete because there are subordinate
tables
Me.sdaOrderDetails.Update(inDS.OrderDetails.Select ("", "", _
DataViewRowState.Added Or DataViewRowState.ModifiedCurrent))
' can add, change, and delete because no subordinate tables
Me.sdaOrderMiscCharges.Update(inDS.OrderDetailMisc Charges)
' only add or modify, can't delete because there are subordinate
tables

Me.sdaOrderDetailComponents.Update(inDS.OrderDetai lComponents.Select("", "", _
DataViewRowState.Added Or DataViewRowState.ModifiedCurrent))
' can add, change, and delete because no subordinate tables

Me.sdaOrderDetailComponentSpeficiations.Update(inD S.OrderDetailComponentSpecifications)

' now pick up the deletes, from the bottom up
Me.sdaOrderDetailComponents.Update(inDS.OrderDetai lComponents)
Me.sdaOrderDetails.Update(inDS.OrderDetails)
Try
Me.sdaOrders.Update(inDS.Orders)
Catch RO_exception As Data.ReadOnlyException
' accept changes manually and continue
inDS.Orders.AcceptChanges()
End Try

"Aaron Smith" wrote:
I fixed this problem. The solution is quite simple. Whenever you call
Update on the dataadapter, just remove the expression and then add it
back after the update is finished:

Dim dc As DataColumn = DataSet.Table.Columns.Item("ExpCol")
Dim exp As String = dc.Expression
dc.Expression = ""
Try
DataAdapter.Update(DataSet, "Table")
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message(), "Error")
Finally
dc.Expression = exp
End Try

I tried to just remove the whole column, then add it back in, but for
some reason I was getting an error message that the column wasn't a
datacolumn or datarelation, so I simplified...

Aaron Smith wrote:
I'm still getting this error, does anyone have any more ideas? I removed
the field from the schema and manually add it and I still get the error
message. The record actually saves, but this error just pops up.. If
there a way to turn error checking off for certain fields? Is it just a
property I am not setting?

Aaron Smith wrote:

> I just added it to the Dataset Schema and then set the expression in
> the new procedure of the form...
>
> CoursesDS1.InstClasses.FullNameColumn.Expression =
> "Parent(InstructorsInstClasses).First_Name + ' ' +
> Parent(InstructorsInstClasses).Last_Name"
>
> Thats the expression...
>
> If that is the only line of code in there, and I don't manually set
> the value, it still does not work.. I still get the same message.
> Should I remove that column from the schema and manually create the
> column and add it to the table?? I think I will try that while waiting
> for other suggestions.
>
> Aaron
>
> Chris, Master of All Things Insignificant wrote:
>
>> How did you add the column to the dataset? You added it to the
>> Table? Can you post some simplified code that shows the problem?
>>
>> Chris
>>
>> "Aaron Smith" <th**********@smithcentral.net> wrote in message
>> news:bb**************@newssvr19.news.prodigy.com.. .
>>
>>> Ok. I have a dataset that has multiple tables in it. In one of the
>>> child tables, I have a column that I added to the DataSet (Not in
>>> the DataSource). This column does not need to be stored in the data
>>> on the datasource. It simply gets the first name and last name of an
>>> instructor and displays it in the grid. I have two major
>>> problems.... One, it doesn't display in the column until the row is
>>> saved, (Even after calling a refresh on the grid) and two, I am
>>> getting a Cannot change ReadOnly property of the expression column
>>> error message when I try to update the datasource. I found a lot of
>>> confusing information that dealt with the column updating the
>>> datasource, etc etc. The column is in none of the commands attached
>>> to the data adapters.
>>>
>>> For the column refresh problem, I added code to manually fill in
>>> that field when leaving a previous column and that seemed to work,
>>> however, it doesn't always show when doing a refresh. I have to
>>> navigate back to that column in order to see it.
>>>
>>> Any ideas on either problem?
>>> Aaron
>>> --
>>> ---
>>> Aaron Smith
>>> Remove -1- to E-Mail me. Spam Sucks.
>>
>>
>>
>>
>>
>
>

--
---
Aaron Smith
Remove -1- to E-Mail me. Spam Sucks.

Nov 21 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.