OLD ado problem with command object

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Kovan A. (kabdulla_at_cpumanagement.com)
Date: 02/05/04


Date: Thu, 5 Feb 2004 16:18:24 -0500

I am having a small problem using old ADO in VB.NET (i am maintaing old code
so i cant change it back to ADO.NET)
i am trying to create ADODB.Parameters and then pass them to ADODB.Command
and it seems to fail every time
I have referenced the adodb.dll in PIA to use the old ado., and i am using
ado 2.7

Parameters is an array of ADODB.Parameter
any help would be appreciated it

Kovan,

here is the code (keep in mind my stored procedure parameters match the
parameters in param()

Dim cmd As New ADODB.Command

cmd.CommandText = strSPName

cmd.CommandType = CommandTypeEnum.adCmdStoredProc

cmd.ActiveConnection = adoConn

'if we were given a parameters collection, append them to the command

If Not Parameters Is Nothing AndAlso Parameters.Length > 0 Then

Dim param As ADODB.Parameter

For Each param In Parameters

cmd.Parameters.Append(param) 'ERROR HAPPENS HERE (InvalidCastException)

Next

End If

cmd.Execute(, , ADODB.ExecuteOptionEnum.adExecuteNoRecords)

rs = Nothing



Relevant Pages

  • old ADO in VB.NET
    ... I am having a small problem using old ADO in VB.NET (i am maintaing old code ... so i cant change it back to ADO.NET) ... Dim cmd As New ADODB.Command ... Dim param As ADODB.Parameter ...
    (microsoft.public.dotnet.languages.vb)
  • using ADO in .NET
    ... I am having a small problem using old ADO in VB.NET (i am maintaing old code ... so i cant change it back to ADO.NET) ... Dim cmd As New ADODB.Command ... Dim param As ADODB.Parameter ...
    (microsoft.public.dotnet.general)
  • Re: SELECT INTO an external database
    ... Dim cmd As New ADODB.Command, ... Dim strConn As String ... ADO can't do bulk inserts to an External DB, ... also use an ADODB Recordset object, but the command object is more ...
    (comp.databases.ms-access)
  • Re: HELP with adodb.command object, PLEASE!!!
    ... Which version of ADO are you using and which version of ADO do you have on ... Dim cmd As ADODB.Command ... > system test and/or production machines, ... > support expected interface." ...
    (microsoft.public.vb.database.ado)
  • Re: Bad variable type exception
    ... Why are you using ADO instead of ADO.NET? ... This is a forum for ADO.NET ... > I have made this function to create a command object to be used to call a ... > Dim cmd As New ADODB.Command ...
    (microsoft.public.dotnet.framework.adonet)