Skip to main content
Kofax

The given value of type String from the data source cannot be converted to type nvarchar of the specified target column

Article # 3029494 - Page views: 18

Article # 3029494 - Page views: 18

Issue

The following error is reported in the IMPORT_ERRORS_MESSAGE field of the ERP_IMPORT_JOB_STATUS table in the AP Agility database, after running the AP Agility data import job: 

(This example is related to the PO Headers): 

Import Time: 00:00:19.4104525  PO Headers:
The given value of type String from the data source cannot be converted to type nvarchar of the specified target column.
   at System.Data.SqlClient.SqlBulkCopy.ConvertValue(Object value, _SqlMetaData metadata, Boolean isNull, Boolean& isSqlType,
Boolean& coercedToDataFeed)
   at System.Data.SqlClient.SqlBulkCopy.ReadWriteColumnValueAsync(Int32 col)
   at System.Data.SqlClient.SqlBulkCopy.CopyColumnsAsync(Int32 col, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.CopyRowsAsync(Int32 rowsSoFar, Int32 totalRows, CancellationToken cts,
TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.CopyBatchesAsyncContinued(BulkCopySimpleResultSet internalResults, String
updateBulkCommandText, CancellationToken cts, TaskCompletionSource`1 source)
   at System.Data.SqlClient.SqlBulkCopy.CopyBatchesAsync(BulkCopySimpleResultSet internalResults, String updateBulkCommandText,
CancellationToken cts, TaskCompletionSource`1 source)
   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 Kofax.ApAgility.DatabaseLib.SqlExecutor.SqlBulkCopy(String tableName, DataTable importedDataTable, SqlConnection
connection, SqlTransaction transaction)
   at Kofax.ApAgility.DatabaseLib.SqlExecutor.<>c__DisplayClass8_0.<Merge>g__Merge|0()
   at Kofax.ApAgility.DatabaseLib.TransientFaultHandler.ExecuteFunc[T](Func`1 func, Boolean transactionContext, String
actionName)
   at Kofax.ApAgility.DatabaseLib.SqlExecutor.Merge(DataTable importedDataTable, String tableName, String
createTempTableStatement, String[] mergeColumns, Boolean clearPreviousRecords)
   at Kofax.ApAgility.ErpIntegration.CsvImporter.ImportRecordsFromStream[T,TMap](TextReader stream, Boolean hasHeaderRecord,
Boolean paginateReading, Func`2 dataTableCreationFunc, String tableName, String createTempTableStatement, String[] mergeColumns,
Boolean clearPreviousRecords, Boolean missingFieldFound)
   at Kofax.ApAgility.ErpIntegration.CsvImporter.ImportPoHeaders(String erpConnectionName)
   at Kofax.ApAgility.ErpIntegration.CsvImporter.<ImportFromErpAssets>g__TryCatchExecute|46_0(Func`1 func, Int32
recordsAlreadyImported, StringBuilder errorMessages, String errorMessage, Boolean status)
 

 

Cause

This error is the result of too many characters in a particular field. For example, in the po headers csv, having more than 50 characters for a vendorsitecode value would cause this error.

In some cases, we have also seen customers attempting to put too much data in the vendorsitecode field, such as an address, which also does not belong in the field. 

 

Solution

Clean your source csv files so that the fields have the appropriate amount and type of data. For example, for po headers vendorsitecode, do not put addresses into this field. If you don't have an appropriate code, leave the field blank. 

 

Level of Complexity 

Moderate

 

Applies to  

Product Version Build Environment Hardware
AP Agility 2.3+      

 

  • Was this article helpful?