[BulkInsert] The given ColumnMapping does not match up with any column in the source
Question
bulkinsert
Service icon
Forge component by Galter

Hi all,

I'm using the BulkInsert component in my application. 

Basically, I have an entity and a list of records of the entity type. I'm doing a BulkInsert of the list records to the entity. I'm using an aggregate to get the physical entity name to pass to the BulkInsert action. In my personal area, the same piece of code is working fine (only with different entities) and in another environment is giving me this error:

BulkInsert: System.InvalidOperationException: The given ColumnMapping does not match up with any column in the source or destination.
at System.Data.SqlClient.SqlBulkCopy.AnalyzeTargetAndCreateUpdateBulkCommand(BulkCopySimpleResultSet internalResults)
at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestContinuedAsync(BulkCopySimpleResultSet internalResults, CancellationToken cts, TaskCompletionSource`1 source)
at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternalRestAsync(CancellationToken cts, TaskCompletionSource`1 source)
at System.Data.SqlClient.SqlBulkCopy.WriteToServerInternalAsync(CancellationToken ctoken)
at System.Data.SqlClient.SqlBulkCopy.WriteRowSourceToServerAsync(Int32 columnCount, CancellationToken ctoken)
at System.Data.SqlClient.SqlBulkCopy.WriteToServer(DataTable table, DataRowState rowState)
   at OutSystems.NssBulkInsert.CssBulkInsert.SqlServerBulkInsert(IOSList recordList, String tableName, String columnsToIgnore, String referenceColumns, Boolean useTableLock, Dictionary`2 recordFields, String Catalog, String ExternalDatabaseConnectionName)
 

Any help?

Thanks!


Hi Bruno,

The error message "The given ColumnMapping does not match up with any column in the source or destination" occurs if :-

  • the ColumnMappings are incorrect
  • you provided an invalid column name for the source or the destination
  • there is more column in the source than in the destination

Do check

  • to provide a correct ColumnMappings
  • all values in the source and destination column name are valid and case sensitive.

Regards,

Swatantra

Swatantra Kumar wrote:

Hi Bruno,

The error message "The given ColumnMapping does not match up with any column in the source or destination" occurs if :-

  • the ColumnMappings are incorrect
  • you provided an invalid column name for the source or the destination
  • there is more column in the source than in the destination

Do check

  • to provide a correct ColumnMappings
  • all values in the source and destination column name are valid and case sensitive.

Regards,

Swatantra

 Hi Kumar, 

I find the extension will have the problem if the DB field name starts with a numeric prefix.


 It will show: 


As the DB is from my client, I would not rename it. 

Is there any solution to fix it ?

Many Thanks, 

Jayson

@bruno - You specifically mentioned that the entity you are writing to and your list of records are of the same entity type, so the idea that your you have provided wrong collumn names or there aren't the same amount number of collumns etc, though technically correct, is bull.

When this happens it is typically because the table that was selected for writing in the DB via the Entities table turned out to be the wrong one - in essence the "Physical_Table_Name" provided is not the one you want. The table names are case sensitive, so first off run a debug and check that there is a record selected from the Entities table, if there is one make sure that the one you got is the correct one (another Espace may have a table with the same name in which case you may get the wrong one) - use "Entity.Espace_Id = GetOwnerEspaceIdentifier()"as one of your filters to be sure of this.

Lastly if this doesn't produce an answer, it may be something simple like the action where you select the entity (which would provide the value for GetOwnerEspaceIdentifier()) is in the wrong Espace. It must be in the Espace that the table is located in, otherwise you wont get a result if you include GetOwnerEspaceIdentifier in the aggregate.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.