187
Views
5
Comments
Solved
[BulkInsert] BulkInsert - Binary Field
Question
bulkinsert
Service icon
Forge component by Galter

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?

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.



Hello, I am experiencing the same problem. Could you be so kind to share the code with the changes that solved your issue? Thanks!

Hello Margarida, sorry I don't have access to this codebase anymore... but even so if I remember correctly I had to add an extra 'If' to the .Net code checking if the input was a binary type and when true adding the data as text.

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.



Hello, I am experiencing the same problem. Could you be so kind to share the code with the changes that solved your issue? Thanks!

Hello Margarida, sorry I don't have access to this codebase anymore... but even so if I remember correctly I had to add an extra 'If' to the .Net code checking if the input was a binary type and when true adding the data as text.

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

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