B
Bob
Hello,
I create a DataSet with 7 empty DataTables - no rows.
I then create 7 "stand-alone" DataTables with same schema - and same
tablename - as the ones in the DS, and query the data source, filling
each DT individually.
At this point if I merge the stand-alone DTs into the "empty" DS it
works fine.
DS.Merge((DT1)
DS.Merge((DT2)
DS.Merge((DT3)
DS.Merge((DT4)
DS.Merge((DT5)
DS.Merge((DT6)
DS.Merge((DT7)
The DS now has DTs with the correct rows - the rows in each DT of the
DS match the rows of its stand-alone DT counterpart.
However, if I try to immediately "re-Merge" all the stand-alone DTs
into the DS (which in reality should Merge nothing into the DS as none
of the rows have changed) I get an error on two of the seven DTs:
"Invalid cast from DateTime to Int16"
I have tried it with DS.EnforceConstraints = True and = False.
There are relationships in the DS, involving all tables. The two DTs
that error have FK constraints, but so, too, do a couple other DTs
that don't error.
To prove that this should work, instead of "re-merging" one of the DTs
that cause the error I loop through each row in the DT and use
LoadDataRow to "merge" the rows in one at a time.
This works!
For i = 0 to DT.Rows.Count - 1
DR = DT.Rows(i)
DS.Tables("MatchingTableNameAsDT").LoadDataRow(DR.ItemArray, False)
Next
I also tried to .Merge the individual DataRows as opposed to
LoadDataRow.
This did not work - produced same error:
Dim aryDR(0) as DataRow
For i = 0 to DT.Rows.Count - 1
aryDR(0) = DT.Rows(i)
DS.Merge(aryDR)
Next
Is this a bug in DataSet.Merge(DataTable) or am I missing something?
Thanks,
Bob
I create a DataSet with 7 empty DataTables - no rows.
I then create 7 "stand-alone" DataTables with same schema - and same
tablename - as the ones in the DS, and query the data source, filling
each DT individually.
At this point if I merge the stand-alone DTs into the "empty" DS it
works fine.
DS.Merge((DT1)
DS.Merge((DT2)
DS.Merge((DT3)
DS.Merge((DT4)
DS.Merge((DT5)
DS.Merge((DT6)
DS.Merge((DT7)
The DS now has DTs with the correct rows - the rows in each DT of the
DS match the rows of its stand-alone DT counterpart.
However, if I try to immediately "re-Merge" all the stand-alone DTs
into the DS (which in reality should Merge nothing into the DS as none
of the rows have changed) I get an error on two of the seven DTs:
"Invalid cast from DateTime to Int16"
I have tried it with DS.EnforceConstraints = True and = False.
There are relationships in the DS, involving all tables. The two DTs
that error have FK constraints, but so, too, do a couple other DTs
that don't error.
To prove that this should work, instead of "re-merging" one of the DTs
that cause the error I loop through each row in the DT and use
LoadDataRow to "merge" the rows in one at a time.
This works!
For i = 0 to DT.Rows.Count - 1
DR = DT.Rows(i)
DS.Tables("MatchingTableNameAsDT").LoadDataRow(DR.ItemArray, False)
Next
I also tried to .Merge the individual DataRows as opposed to
LoadDataRow.
This did not work - produced same error:
Dim aryDR(0) as DataRow
For i = 0 to DT.Rows.Count - 1
aryDR(0) = DT.Rows(i)
DS.Merge(aryDR)
Next
Is this a bug in DataSet.Merge(DataTable) or am I missing something?
Thanks,
Bob