This seems like it should be simple, but I can't seem to get it to work. I'm trying to send Forms attachments to SQL. I've got [Retrieve Business Process Variables] passing the File Upload file collection to the [For Each File]. Inside the loop, I'm trying to pass %(ForEachFile_CurrentFile) to the varbinary(max) column in the SQL table. I've tried the [Insert Data] activity, which fails with the error "Implicit conversion from data type nvarchar to varbinary(max) is not allowed. Use the CONVERT function to run this query.", and the [Custom Query] activity, which fails with "Failed to convert parameter value from a String to a Byte[].".
What am I missing?
Edit after continuing to bang my head against this:
Based on this:
and the fact that CurrentFile does show up in the token dialog, it seems that I should only need to do this:
But that throws the aforementioned errors. Since I couldn't figure out what it's trying to convert from a string, I tried pushing the token into a VARCHAR column instead and got "43:\4b3b10b4-4dea-498c-b212-b81f7765777a\RetrieveBusinessProcessVariables\2039\120206.pdf", so something seems to be preventing the token from actually carrying the file data.
Well, if the %(ForEachFile_CurrentFile) token is broken, maybe I can work around it: %(ForEachFile_CurrentFile_Source ID) appears to be the attachment_id from cf_bp_attachment_data, so we should be able to get the file data directly from the table instead:
This throws a warning that "Column 'attachment' is returning a large amount of data...", which would seem to indicate that we're successfully getting the file data out of the Forms table. I'm still getting the same errors on attempting to insert the data, however.