[BulkInsert] BulkInsert - Binary Field

[BulkInsert] BulkInsert - Binary Field

  
Forge Component
(11)
Published on 25 Jun by Marcelo Ferreira
11 votes
Published on 25 Jun by Marcelo Ferreira

Hello, I'm trying to use BulkInsert onto a table with a Binary field, currently I running a SQLServer DB, but I get the follow error when doing the insert:

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

Any ideas?

You are trying to insert a field of type string into a binary field

Solution

Hum... no actualy I'm not.

Searching a bit more around the error and the classes used on the xif I founded this: https://stackoverflow.com/questions/2001715/how-can-i-use-sqlbulkcopy-with-binary-data-byte-in-a-datatable

Adding a if to verify if the type I'm passing is an array of bytes and forcing the field to use it resolved my problem... Whitout it the SqlBulkCopy would treat the field as String giving me the reported error.



Solution

Try to edit the extension and replace that particular piece of code to see whats happening