As @Richard-MacCutchan has already pointed out, the problem in line
cmd.parameters.append cmd.createParameter("@vbin_Document", adVarBinary, adParamInput, -1, Document)
is that you have given a data size of -1.
If you are not sure what the size should be then you would normally omit it entirely rather than use an impossible value (nothing can be -1 in length), but if you check the documentation CreateParameter Method (ADO) - SQL Server | Microsoft Docs
] you will note
Quote:If you specify a variable-length data type in the Type argument, you must either pass a Size argument or set the Size property of the Parameter object before appending it to the Parameters collection; otherwise, an error occurs.
Unfortunately you haven't given us enough code to determine exactly how to find out the size of the variable
, but you should calculate that first and use that value when creating the parameter.
Alternatively, you could work out the defined size of the field and use that - see DefinedSize Property - SQL Server | Microsoft Docs
At worst, you could just use a large number (not recommended, backstop only)
cmd.parameters.append cmd.createParameter("@vbin_Document", adVarBinary, adParamInput, 8000, Document)
Personally, I never store documents in databases - I store them on a File System (it's what they are designed for after all) and record the location
of the file on the database as a string (along with other information for integrity checks such as date last amended, hash value). Having been caught out previously I also only store the path relative to a "base folder" - we had to move repository once and the server name had been embedded in the data - it was not a fun time.
You would still have to provide the length of the data, but it would be trivial to work out, or you could just use the max path length of 260