Skip to main content

hi,

i'm trying to upload a file in sql server. i have my file in a data of type "binary" in my workflow.

I use the wizard of the event "SQL Data" to upload it in my sql server table, in a column of type "binary". Then when i run the process i get an error message saying that it's impossible to convert from varchar to binary. (varchar = string in sqlserver).

How am i supposed to upload this file in sql server? what am i doing wrong?

Thanks for your help.
 

I don't think you'll be able to use the 'SQL Data' even to upload this because this template creates a straight SQL statement under the covers (you can view it by clicking "Edit Code" for this event).  As I understand it in ADO.NET, binary data must be inserted via parameters. 


You could write the parameterized ADO.NET code within a Server Event.  The ADO.NET would expect a byte array (bytey]), which is the actual binary data.  This can be retrieved via the below call (where "EmbeddedFile" is the binary process data field).


 byte ] oBuf = (System.Byte.]) K2.ProcessInstance.DataFieldsi"EmbeddedFile"].Value;


At this point it you can write normal ADO.NET code within the server event to insert the binary data.  There are a number of examples on the internet that show how to insert Binary data into SQL via ADO.NET via the use of a paramertized query.


You will not be able to do it using SQL Data event. Use Server Event with custom code instead, where just put bytes from your binary field manually.


Reply