Help with error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Darth Ferret

    #1

    Help with error

    On the last statement below, I am getting this error -
    'System.Invalid CastException'

    Does anyone know what is causing this? I am trying to pass a parameter to a
    stored procedure in an iseries. My connection opens and I can call a stored
    procedure with no parameters. The problem is that I cannot pass any
    parameters.

    'create command object

    Dim cmd As New iDB2Command(sql , cn

    Dim cmdparm1 As New OleDb.OleDbPara meter("QRYNAME" , OleDb.OleDbType .Char,
    10)

    cmd.Parameters. Clear()

    cmdparm1.Value = "SUNTR401A"

    cmdparm1.Direct ion = ParameterDirect ion.InputOutput

    cmd.Parameters. Add(cmdparm1)



    Thanks in advance,

    Joe in Florida


  • =?Utf-8?B?S2VycnkgTW9vcm1hbg==?=

    #2
    RE: Help with error

    Darth,

    Shouldn't your parameter be of type iDB2Parameter and not OleDbParameter?

    And shouldn't you be using iDB2DbType.iDB2 VarChar as the datatype, etc?

    Kerry Moorman


    "Darth Ferret" wrote:
    On the last statement below, I am getting this error -
    'System.Invalid CastException'
    >
    Does anyone know what is causing this? I am trying to pass a parameter to a
    stored procedure in an iseries. My connection opens and I can call a stored
    procedure with no parameters. The problem is that I cannot pass any
    parameters.
    >
    'create command object
    >
    Dim cmd As New iDB2Command(sql , cn
    >
    Dim cmdparm1 As New OleDb.OleDbPara meter("QRYNAME" , OleDb.OleDbType .Char,
    10)
    >
    cmd.Parameters. Clear()
    >
    cmdparm1.Value = "SUNTR401A"
    >
    cmdparm1.Direct ion = ParameterDirect ion.InputOutput
    >
    cmd.Parameters. Add(cmdparm1)
    >
    >
    >
    Thanks in advance,
    >
    Joe in Florida
    >
    >
    >

    Comment

    • RobinS

      #3
      Re: Help with error


      Why are you declaring the parameter as InputOutput? Are you going to read
      the parameter after the query is executed?

      Isn't OleDbType.Char used for a fixed-length character field; should it be
      VarChar? If you have a fixed-length field, put a space on the end of your
      value, because it's only 9 characters.

      Is your parameter name really QRYNAME?

      How are you executing the stored procedure? There's no code here showing
      that.

      And you're missing a parentheses on the end of the "Dim cmd as New ..."
      line, but I figured that was a typo.

      What does your stored procedure look like?

      Robin S.
      ---------------------------

      "Darth Ferret" <noneavailable@ nowhere.comwrot e in message
      news:%23z5otszQ HHA.3812@TK2MSF TNGP06.phx.gbl. ..
      On the last statement below, I am getting this error -
      'System.Invalid CastException'
      >
      Does anyone know what is causing this? I am trying to pass a parameter to
      a stored procedure in an iseries. My connection opens and I can call a
      stored procedure with no parameters. The problem is that I cannot pass
      any parameters.
      >
      'create command object
      >
      Dim cmd As New iDB2Command(sql , cn
      >
      Dim cmdparm1 As New OleDb.OleDbPara meter("QRYNAME" , OleDb.OleDbType .Char,
      10)
      >
      cmd.Parameters. Clear()
      >
      cmdparm1.Value = "SUNTR401A"
      >
      cmdparm1.Direct ion = ParameterDirect ion.InputOutput
      >
      cmd.Parameters. Add(cmdparm1)
      >
      >
      >
      Thanks in advance,
      >
      Joe in Florida
      >
      >

      Comment

      Working...