Re: Passing VARBINARY/BINARY param to a stored proc

From: Doug Stoltz (NoSpam_at_MyEmail.com)
Date: 08/25/04


Date: Wed, 25 Aug 2004 16:24:21 -0400

I'm having similar problem. With the following

'***********************************************
   dim a_Value as variant 'NOTE: variant does not seem to work here ????
   a_Value = "abcdefghi"

   Dim l_Param As ADODB.Parameter
   Set l_Param = m_ADO_Command.CreateParameter("Fieldx", adVarBinary,
adParamInput, Len(a_Value), a_Value)
   Call m_ADO_Command.Parameters.Append(l_Param)
'***********************************************
The CreateParameter takes a Variant datatype as the Value, but it obviously
does not like it. Is the Byte array the correct way to do this???

Thanks

"Chris" <chrisx@NOSPAM.com> wrote in message
news:OfG9KgshEHA.1184@TK2MSFTNGP12.phx.gbl...
> 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: shape range help
    ... However initial use of Dim() avoided use of brackets and he ... Everytime with ReDim only, I get a Variant() ... never in a session I don't do the initial Dim varr() then redim does NOT ...
    (microsoft.public.excel.programming)
  • Re: Coding with varsortby and options
    ... Dim varhowsort As Variant ... DoCmd.OpenReport stDocName, acViewPreview ...
    (microsoft.public.access.formscoding)
  • Re: shape range help
    ... However initial use of Dim() avoided use of brackets and he ... Everytime with ReDim only, I get a Variant() ... Dim Stooges As ShapeRange ...
    (microsoft.public.excel.programming)
  • Re: OPENFILENAME A P I. User cancels ?
    ... The variable FName will be a Boolean False if no file was selected or a String containing the fully qualified file name if the user selectes a file. ... Const ahtOFN_OVERWRITEPROMPT = &H2 ... Function GetOpenFile(Optional varDirectory As Variant, ... Dim strFilter As String ...
    (microsoft.public.excel.programming)
  • Re: Coding with varsortby and options
    ... Dim varhowsort As Variant ... DoCmd.OpenReport stDocName, acViewPreview ...
    (microsoft.public.access.formscoding)