Data row field turns read only and restrict update

Have anyone faced this issue where data field turns read only and when we try to update the value, it throws the exception.

Exception has been thrown by the target of an invocation.| System.Data.ReadOnlyException: Column ‘RequestType’ is read only.
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at System.Data.DataRow.set_Item(String columnName, Object value)

Hi @niteshvnr

Can you give us some background on this. How this datarow variable is used and from where it is taken

Hi,

This happens when I do SQL query and save result to datatable. I am not fetching any value for the column from database, just using some random string to fill the field:

select [Shipment], ‘empty’ as [Column1]
from Table1

I can assing values to [Shipment], but to to [Column1], as it is read only.

An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ----> System.Data.ReadOnlyException: Column ‘Column1’ is read only.
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at System.Data.DataRow.set_Item(String columnName, Object value)

Hi

I have 2 questions regarding this thread.

  1. How did You guys deal with the read only issue?
  2. How do You get such a robust error description? - i got only “Exception has been thrown by the target of an invocation.” and wasted a day looking for a solution (which is very hard to find) until i finally stumbled upon Your thread

Regards
Jakrec

I re-enabled the read-only Datatable column by doing the following:

datatableVariable.Columns("ColumnName").ReadOnly = False