We are currently trying to insert rows in a database however one of our field (hashfile) has to be converted to a varbinary.
I do not find how to do that in Easymorph directly and, as far as I know, it is not possible to write a custom SQL command using the dataset from the table.
Here is the error that we receive:
Error: The given value of type String from the data source cannot be converted to type varbinary of the specified target column.
Failed to convert parameter value from a String to a Byte.
Invalid cast from 'System.String' to 'System.Byte'.
Source: action "Bulk export to database", module "Main", table "XXXXXXXXXXXXXXX"
Do you know how we could solve this issue as we cannot change the data type in our database ? Thank you for your help.
Create a temporary table with the same structure as the target table but with the type of the varbinary column set to varchar or a similar type.
Export your data to that temporary table as usual.
Copy data from the temporary table to the target table with a query that convertovert the text column to the varbinary data type.
Drop the temporary table.
Another workaround is to generate a new dataset column with INSERT queries that contain data from each row and then execute those queries one by one using the “Iterate” action and a submodule with the “Custom command” command from the “Database command” action. But if you have to export more than a couple of dozen of rows, this workaround will be much slower than both the initial simple export and the first workaround.