I have two tables in two different servers. That tables have same columns but in different order and I cant perform bulk copy;
I'm tried to do
var copier = new SqlBulkCopy(destination_connection);
copier.DestinationTableName = destination_table_name;
foreach (DataColumn column in source_table.Columns) {
var mapping = new SqlBulkCopyColumnMapping(column.ColumnName, column.ColumnName);
copier.ColumnMappings.Add(mapping);
}
copier.WriteToServer(source_table);
but this not helps me and InvalidOperationException is raised.
p.s. I use .NET 4.0
EDIT 1:
Exception is
Specified ColumnMapping does not match any column in the data source or destination.
but I sure that all columns have the same name and type. Is there any way to find out which one mapping cause to error?