Exception copying dataset

C

Corey Wirun

Hi All,

I've got a puzzling situation. I have a strongly-typed DataSet with 3
tables which I want to copy into a generic DataSet. So I do this:

DataSet ds = null;
StrongDataSet dsStrong = new StrongDataSet();
Dosomething( ref dsStrong );

ds = dsStrong.Copy();

An exception is thrown on the copy (following). I dump the strong dataset
to an XML file previously and it looks fine.

at System.Data.Index.Sort(Int32 left, Int32 right)
at System.Data.Index.Sort(Int32 left, Int32 right)
at System.Data.Index.Sort(Int32 left, Int32 right)
at System.Data.Index.Sort(Int32 left, Int32 right)
at System.Data.Index.Sort(Int32 left, Int32 right)
at System.Data.Index.Sort(Int32 left, Int32 right)
at System.Data.Index.Sort(Int32 left, Int32 right)
at System.Data.Index.InitRecords()
at System.Data.Index..ctor(DataTable table, Int32[] indexDesc,
DataViewRowState recordStates, IFilter rowFilter)
at System.Data.DataTable.GetIndex(Int32[] indexDesc, DataViewRowState
recordStates, IFilter rowFilter)
at System.Data.DataColumn.get_SortIndex()
at System.Data.DataColumn.IsNotAllowDBNullViolated()
at System.Data.DataSet.EnableConstraints()
at System.Data.DataSet.set_EnforceConstraints(Boolean value)
at System.Data.DataSet.Copy()
at Ahlapi.CAhlapi.GetPlantReport(PlantReportTypeEnum type, ArrayList
reportParams, DataSet& ds) in e:\devel\ahlapi\cahlapi.cs:line 664
2004-06-29 09:59:14,187 [2876] FATAL Ahlapi.CAhlapi [] - Index was outside
the bounds of the array.
2004-06-29 09:59:15,265 [2876] FATAL Ahlapi.CAhlapi [] - System.Data

Any ideas anyone!

Thanks!
Corey.
 
C

Corey Wirun

FYI, I tried:

dsStrong.AcceptChanges()

on the DataSet before the copy and I got the same exception as well. So
something is a little flaky on the DataSet?

Corey.
 
C

Corey Wirun

Okay, I had a closer look at the source DataSet, and there were some NaN
columns. Turns out I was doing a divide by zero in the calculation of one
of the columns.

I don't know why an exception wasn't thrown on the divide - leading to the
NaN getting saved in the table, but fixing it fixed my Copy problem.

Ergh. :)
Corey.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top