The Crystal Report was developed and worked fine in version 10.5 and under Visual Studio 2008 (.NET framework 3.5). However, when migrated to Version 13.0.2 and Visual Studio 2010 (.NET framework 4.0). I got the error below:
Anyone had the similar experience? Any help or solution would be welcome.
Message: A column named '**Item**' already belongs to this DataTable. Source: System.Data Current Method: Void RegisterColumnName(System.String, System.Data.DataColumn) Stack Trace: at System.Data.DataColumnCollection.RegisterColumnName(String name, DataColumn column) at System.Data.DataColumnCollection.BaseAdd(DataColumn column) at System.Data.DataColumnCollection.AddAt(Int32 index, DataColumn column) at System.Data.DataColumnCollection.Add(String columnName, Type type) at CrystalDecisions.CrystalReports.Engine.Table.BuildTableFromMemberInfos(ArrayList memberInfos, Boolean autoFlattenCurrentLevel, Int32 currentLevel, Int32 maximumLevels, String namePrefix, DataTable table) at CrystalDecisions.CrystalReports.Engine.Table.BuildTableFromEnumerable(IEnumerable collection, Type dataClassType, String tableName) at CrystalDecisions.CrystalReports.Engine.Table.EnumerableToDataSet(IEnumerable collection) at CrystalDecisions.CrystalReports.Engine.Table.WrapAndCacheDotNetObject(Object val, Type type, ISCRAdoNetDataSet& crAdoNetDataSet) at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(Object val, Type type) at CrystalDecisions.CrystalReports.Engine.Table.SetDataSource(IEnumerable enumerable)*
Added the source code, DetailSps and other dataset are defined in a .xsd file. The error is from: Report.Database.Tables["DetailSps"].SetDataSource:
public void CreateReport(ReportInfo reportInfo)
{
PopulateReportData(reportInfo.SpecDetail.Table);
ReportClass Report = new DetailsRpt();
Report.ReportOptions.EnableSaveDataWithReport = true;
Report.ReportOptions.EnableSaveSummariesWithReport = true;
// now add the tables used in Report
Report.Database.Tables["DetailSps"].SetDataSource(
DetailSps.OrderBy(x => x.ID)
.ThenBy(x => x.Specall_ID));
.....
}
private void PopulateReportData(DataTable dt)
{
foreach (DataRow dr in dt.Rows)
{
DetailSps.AddDetailsRow(
(String)dr["ID"],
(String)dr["Type"],
CommonDateFunctions.FormatStringAsDateMDYYYY(dr["selected_date"].ToString()),
......
(String)dr["ErrorCode"]
);
}
....
}