G
Guest
Creating a new dataset from an existing one using ImportRow works just fine
but when I want to modify the DataColumn of the imported rows inside the new
dataset I always get an error saying that the column is read-only ?!?!?!
"System.Data.ReadOnlyException: Column 'start' is read only.
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at System.Data.DataRow.set_Item(String columnName, Object value)
at Periods.currentPeriods(Int32 offSet) in
c:\inetpub\wwwroot\WebServices\RossWS\App_Code\RossServices.vb:line 45"
Here part of the code
newDataset = existingDataSet.Clone
Dim copyRows() As DataRow = existingDataSet.Tables(0).Select
Dim periodsTable As DataTable = newDataset.Tables(0)
Dim copyRow As DataRow
For Each copyRow In copyRows
periodsTable.ImportRow(copyRow)
Next
For i = 0 To periodsTable.Rows.Count - 1
periodsTable.Rows(i)("start") = CType(periodsTable.Rows(i)("start"),
DateTime).AddHours(offSet)
periodsTable.Rows(i)("end") = CType(periodsTable.Rows(i)("end"),
DateTime).AddHours(offSet + 24)
Next i
Thanks
but when I want to modify the DataColumn of the imported rows inside the new
dataset I always get an error saying that the column is read-only ?!?!?!
"System.Data.ReadOnlyException: Column 'start' is read only.
at System.Data.DataRow.set_Item(DataColumn column, Object value)
at System.Data.DataRow.set_Item(String columnName, Object value)
at Periods.currentPeriods(Int32 offSet) in
c:\inetpub\wwwroot\WebServices\RossWS\App_Code\RossServices.vb:line 45"
Here part of the code
newDataset = existingDataSet.Clone
Dim copyRows() As DataRow = existingDataSet.Tables(0).Select
Dim periodsTable As DataTable = newDataset.Tables(0)
Dim copyRow As DataRow
For Each copyRow In copyRows
periodsTable.ImportRow(copyRow)
Next
For i = 0 To periodsTable.Rows.Count - 1
periodsTable.Rows(i)("start") = CType(periodsTable.Rows(i)("start"),
DateTime).AddHours(offSet)
periodsTable.Rows(i)("end") = CType(periodsTable.Rows(i)("end"),
DateTime).AddHours(offSet + 24)
Next i
Thanks