Complete error message
System.ArgumentException: The input array is longer than the number of columns in this table.
In System.Data.DataTable.NewRecordFromArray (object[] value)
In System.Data.DataRowCollection.Add (object[] values)
In \mainfrm.importdb_insertrecord (OleDbTransaction Dbtran, DataTable desttable, String InsertCommand, DataRow dr_src, String Pkcolumnname, int32& primarykeyvalue, FilterColumn filtercolumn) location J:\csProjects\Main.cs: line number 2636
In \mainfrm.importdb_importtable (OleDbConnection con_src, OleDbTransaction Dbtran, String tableName, FilterColumn FilterColumn) Location J:\csProjects\Main.cs: line number 2573
In \mainfrm.importdb_importcontract (OleDbConnection con_src, OleDbTransaction Dbtran, String projectid_src, Int32& Impcontract_exist, int32& impcontract_succe) location J:\csProjects\Main.cs: Line No. 2519
In \mainfrm.importdb_importproject (String srcdbfilepath) position J:\csProjects\Main.cs: line number 2382
Error code line
destTable.Rows.Add(dr_src.ItemArray);
The desttable type is: System.Data.DataTable
The type of DR_SRC is: System.Data.DataRow
Cause of error
DR_SRC contains more columns than the number of columns desttable contains.
Solution Solutions
Generates a new row based on the structure of the Target data table, and then fills the fields one by one;
DataRow dr_new = destTable.NewRow();in destTable.Columns){ if (dr_src.Table.Columns.Contains(dc.ColumnName)) { dr_new[dc.ColumnName] = dr_src[dc.ColumnName]; }}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
System.ArgumentException: The input array is longer than the number of columns in this table.