M
Mark Sherwood
When running the code the following error is displayed when setting either
the value or appendchunk for the file data.
Run-time error '3421':
Application uses a value of the wrong type for the current operation.
The code is from VBA using ADO 2.7 connecting to a stored procedure in SQL
Server 2000 that has the parameter defined as an Image data type.
How can the image data type be used in ADO to send file data to a stored
procedure?
' get binary data
Set aStream = New ADODB.Stream
aStream.Charset = "ascii"
aStream.Type = adTypeBinary
aStream.Open
aStream.LoadFromFile "C:\aSample.pdf"
aStream.Position = 0
Set prm = New ADODB.Parameter
prm.Name = "@DocFileSize"
prm.Type = adInteger
prm.Size = 3
prm.Direction = adParamInput
prm.Value = aStream.Size
com.Parameters.Append prm
Set prm = Nothing
Set prm = New ADODB.Parameter
prm.Name = "@DocFileData"
prm.Type = adLongVarBinary
prm.Size = 16
prm.Direction = adParamInput
prm.Value = aStream.Read
'prm.AppendChunk aStream.Read
com.Parameters.Append prm
Set prm = Nothing
' close file
aStream.Close
Set aStream = Nothing
the value or appendchunk for the file data.
Run-time error '3421':
Application uses a value of the wrong type for the current operation.
The code is from VBA using ADO 2.7 connecting to a stored procedure in SQL
Server 2000 that has the parameter defined as an Image data type.
How can the image data type be used in ADO to send file data to a stored
procedure?
' get binary data
Set aStream = New ADODB.Stream
aStream.Charset = "ascii"
aStream.Type = adTypeBinary
aStream.Open
aStream.LoadFromFile "C:\aSample.pdf"
aStream.Position = 0
Set prm = New ADODB.Parameter
prm.Name = "@DocFileSize"
prm.Type = adInteger
prm.Size = 3
prm.Direction = adParamInput
prm.Value = aStream.Size
com.Parameters.Append prm
Set prm = Nothing
Set prm = New ADODB.Parameter
prm.Name = "@DocFileData"
prm.Type = adLongVarBinary
prm.Size = 16
prm.Direction = adParamInput
prm.Value = aStream.Read
'prm.AppendChunk aStream.Read
com.Parameters.Append prm
Set prm = Nothing
' close file
aStream.Close
Set aStream = Nothing