Passing VARBINARY/BINARY param to a stored proc

From: Chris (chrisx_at_NOSPAM.com)
Date: 08/20/04


Date: Fri, 20 Aug 2004 16:11:57 +0100

My VB6 program is having problems using ADO (2.7) to pass a Byte array to a
VARBINARY parameter in an SQL Server 2000 stored procedure. I get an error
"3421:Application uses a value of the wrong type for the current operation"
when calling the Execute method.

If I set Parameter(2).Value = Null then everything works OK. I've confirmed
that I'm updating the correct ADOParameter. Prior to calling Execute, the
Value is an array. I've even commented out the stored procedure code so
that the parameter is ignored. Can someone point me in the right direction
please?

My code is as follows:-

Dim vData() As Byte
Dim Proc As Command

// Code to redimension & populate vData()...

Set Proc = New ADODB.Command
With Proc
  Set .ActiveConnection = myDatabase.Connection
  .CommandText = "MY_PROCEDURE"
  .CommandType = adCmdStoredProc
  .Parameters(1).Value = 1
  .Parameters(2).AppendChunk vData()
  .Execute
End With



Relevant Pages

  • Re: rpgle, pcml & arrays
    ... allocation. ... If the program allocates memory on demand to store the array, ... SQL provides a way for a stored procedure to return a result set. ...
    (comp.sys.ibm.as400.misc)
  • Re: Passing arrays to a stored procedure
    ... sql developers around the world and Joe your attitude was quite frankly rude ... I am also writing a stored procedure and have to put an array of values into ... > into scalars. ...
    (microsoft.public.sqlserver.programming)
  • Re: rpgle, pcml & arrays
    ... can construct result set from a query or from an array. ... look at the SET RESULT SETS FOR CURSOR statement. ... SQL or in a store procedure in SQL stored procedure statements. ... doesn't support dynamic lenght parameters in the invoked ile code. ...
    (comp.sys.ibm.as400.misc)
  • Re: Stored procedure to set defaults
    ... AFields() will give you an array of field names, types, etc. ... >I dont know the basis of stored procedure.. ... > "Dan Freeman" wrote in message ...
    (microsoft.public.fox.vfp.dbc)