Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. DB2 Store procedure error in VB.NET

DB2 Store procedure error in VB.NET

Scheduled Pinned Locked Moved Database
databasehelpcsharpsharepoint
27 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G GuyThiebaut

    You will need something like Toad [^]then call the stored procedure from there. I always test stored procedures form a client before running them from .Net.

    “That which can be asserted without evidence, can be dismissed without evidence.”

    ― Christopher Hitchens

    S Offline
    S Offline
    sudevsu
    wrote on last edited by
    #18

    Ok Thank you. I did that now, it is perfectly ok there. But from code it goes into catch and throws same error no matter what. :(

    Your help is much appreciated. Thanks Happy Coding!

    1 Reply Last reply
    0
    • G GuyThiebaut

      Instead of this:

      Dim cm As New iDB2Command("CALL DEVSUSH.SP_CUSTINFO(@PrmCICID,@PrmCIFN,@PrmCILN,@PrmCIADDR,@PrmCICITY,@PrmCISTATE,@PrmCIZIP,@PrmCIPHONE,@PrmCIEMAIL,@PrmCICLDATE)", Cn)

      Try this:

      Dim cm As New iDB2Command("CALL DEVSUSH.SP_CUSTINFO(?,?,?,?,?,?,?,?,?,?)", Cn)

      and read this[^] [edit] ? added

      “That which can be asserted without evidence, can be dismissed without evidence.”

      ― Christopher Hitchens

      S Offline
      S Offline
      sudevsu
      wrote on last edited by
      #19

      I tried the one which you said and Now this is throwing

      SQL0440 Routine QZ9AFC1C3BBACE2001 in not found with specified parameters.

      Your help is much appreciated. Thanks Happy Coding!

      G 1 Reply Last reply
      0
      • S sudevsu

        I tried the one which you said and Now this is throwing

        SQL0440 Routine QZ9AFC1C3BBACE2001 in not found with specified parameters.

        Your help is much appreciated. Thanks Happy Coding!

        G Offline
        G Offline
        GuyThiebaut
        wrote on last edited by
        #20

        sudevsu wrote:

        I tried the one which you said and Now this is throwing

        The one with the "?" question marks for parameters?

        “That which can be asserted without evidence, can be dismissed without evidence.”

        ― Christopher Hitchens

        S 1 Reply Last reply
        0
        • G GuyThiebaut

          sudevsu wrote:

          I tried the one which you said and Now this is throwing

          The one with the "?" question marks for parameters?

          “That which can be asserted without evidence, can be dismissed without evidence.”

          ― Christopher Hitchens

          S Offline
          S Offline
          sudevsu
          wrote on last edited by
          #21

          with ? I get this error

          SQL0104 Token PRMCICID was not valid. Valid tokens: ) ,.

          Your help is much appreciated. Thanks Happy Coding!

          G 1 Reply Last reply
          0
          • S sudevsu

            with ? I get this error

            SQL0104 Token PRMCICID was not valid. Valid tokens: ) ,.

            Your help is much appreciated. Thanks Happy Coding!

            G Offline
            G Offline
            GuyThiebaut
            wrote on last edited by
            #22

            Read this[^] article - I think it should help.

            “That which can be asserted without evidence, can be dismissed without evidence.”

            ― Christopher Hitchens

            S 1 Reply Last reply
            0
            • G GuyThiebaut

              Read this[^] article - I think it should help.

              “That which can be asserted without evidence, can be dismissed without evidence.”

              ― Christopher Hitchens

              S Offline
              S Offline
              sudevsu
              wrote on last edited by
              #23

              Thanks Guy. I wish this should resolve ASAP. It is taking my whole lot of time. :doh:

              Your help is much appreciated. Thanks Happy Coding!

              1 Reply Last reply
              0
              • S sudevsu

                You mean just remove all @. Do I need to add ? or something instead of @?

                Your help is much appreciated. Thanks Happy Coding!

                J Offline
                J Offline
                Jorgen Andersson
                wrote on last edited by
                #24

                Not in the procedure just remove them like this:

                INSERT INTO DEVSUSH . CLCUSINF ( CICID , CIFN , CILN , CIADDR , CICITY , CISTATE , CIZIP , CIPHONE , CIEMAIL , CICLDATE )
                VALUES ( PRMCICID , PRMCIFN , PRMCILN , PRMCIADDR , PRMCICITY , PRMCISTATE , PRMCIZIP , PRMCIPHONE , PRMCIEMAIL , PRMCICLDATE ) ;

                But your call from vb.net to the database is a prepared statement so that should be changed to:

                    Try
                        Dim cm As New iDB2Command("CALL DEVSUSH.SP\_CUSTINFO(:PrmCICID,:PrmCIFN,:PrmCILN,:PrmCIADDR,:PrmCICITY,:PrmCISTATE,:PrmCIZIP,:PrmCIPHONE,:PrmCIEMAIL,:PrmCICLDATE)", Cn)
                        strCIPHONE = strCIPHONE.Replace("-", "")
                        cm.Parameters.Add("PRMCICID", iDB2DbType.iDB2Numeric).Value = Convert.ToInt32(strCICID)
                        cm.Parameters.Add("PrmCIFN", iDB2DbType.iDB2VarChar).Value = strCIFN
                        cm.Parameters.Add("PrmCILN", iDB2DbType.iDB2VarChar).Value = strCILN
                        cm.Parameters.Add("PrmCIADDR", iDB2DbType.iDB2VarChar).Value = strCIADDR
                        cm.Parameters.Add("PrmCICITY", iDB2DbType.iDB2VarChar).Value = strCICITY
                        cm.Parameters.Add("PrmCISTATE", iDB2DbType.iDB2VarChar).Value = strCISTATE
                        cm.Parameters.Add("PrmCIZIP", iDB2DbType.iDB2Numeric).Value = Convert.ToInt32(strCIZIP)
                        cm.Parameters.Add("PrmCIPHONE", iDB2DbType.iDB2Numeric).Value = Convert.ToInt64(strCIPHONE)
                        cm.Parameters.Add("PrmCIEMAIL", iDB2DbType.iDB2VarChar).Value = strCIEMAIL
                        cm.Parameters.Add("PrmCICLDATE", iDB2DbType.iDB2Date).Value = strCICLDATE
                        cm.ExecuteNonQuery()
                    Catch ex As Exception
                        LogError.LogErrorIntoTextFile(ex, "InsertCust")
                    End Try
                

                Should note that the error message you're getting is not from DB2 but from VB.Net, stating that there is a mismatch in the parameters. Or rather that it can't find an overload of the procedure having the right parameters. The reason it works is that it tries to apply the parameters in the order they've been added like as if you had used ? as a marker. Like this:

                Dim cm As New iDB2Command("CALL DEVSUSH.SP_CUSTINFO(?,?,?,?,?,?,?,?,?,?)", Cn)

                Wrong is evil and must be defeated. - Jeff Ello

                1 Reply Last reply
                0
                • S sudevsu

                  I have a store procedure in my DB2 Database. It is just a simple insert statement. I have 10 columns in the table and each value is passed as a parameter to Store procedure and when I execute it throws an error

                  Overload resolution failed because no accessible 'Parameters' accepts this number of arguments.

                  My Store procedure is

                  CREATE PROCEDURE DEVSUSH.SP_CUSTINFO (
                  IN PRMCICID INTEGER ,
                  IN PRMCIFN VARCHAR(30) ,
                  IN PRMCILN VARCHAR(30) ,
                  IN PRMCIADDR VARCHAR(90) ,
                  IN PRMCICITY VARCHAR(20) ,
                  IN PRMCISTATE VARCHAR(20) ,
                  IN PRMCIZIP NUMERIC(9, 0) ,
                  IN PRMCIPHONE NUMERIC(10, 0) ,
                  IN PRMCIEMAIL VARCHAR(30) ,
                  IN PRMCICLDATE DATE )
                  LANGUAGE SQL
                  SPECIFIC DEVSUSH.SP_CUSTINFO
                  NOT DETERMINISTIC
                  MODIFIES SQL DATA
                  CALLED ON NULL INPUT
                  SET OPTION ALWBLK = *ALLREAD ,
                  ALWCPYDTA = *OPTIMIZE ,
                  COMMIT = *NONE ,
                  DECRESULT = (31, 31, 00) ,
                  DFTRDBCOL = *NONE ,
                  DYNDFTCOL = *NO ,
                  DYNUSRPRF = *USER ,
                  SRTSEQ = *HEX
                  P1 : BEGIN
                  INSERT INTO DEVSUSH . CLCUSINF ( CICID , CIFN , CILN , CIADDR , CICITY , CISTATE , CIZIP , CIPHONE , CIEMAIL , CICLDATE ) VALUES ( @PRMCICID , @PRMCIFN , @PRMCILN , @PRMCIADDR , @PRMCICITY , @PRMCISTATE , @PRMCIZIP , @PRMCIPHONE , @PRMCIEMAIL , @PRMCICLDATE ) ;
                  END P1 ;

                  GRANT ALTER , EXECUTE
                  ON SPECIFIC PROCEDURE DEVSUSH.SP_CUSTINFO
                  TO SUSHDEV ;

                  GRANT EXECUTE
                  ON SPECIFIC PROCEDURE DEVSUSH.SP_CUSTINFO
                  TO VAIGROUP ;

                  How to solve the error?

                  Your help is much appreciated. Thanks Happy Coding!

                  M Offline
                  M Offline
                  Mycroft Holmes
                  wrote on last edited by
                  #25

                  A thought, have you checked that there are no triggers spit attached to the table and the error is generated from the trigger instead of your procedure (this is the reason I loathe triggers spit)?

                  Never underestimate the power of human stupidity RAH

                  1 Reply Last reply
                  0
                  • S sudevsu

                    I have a store procedure in my DB2 Database. It is just a simple insert statement. I have 10 columns in the table and each value is passed as a parameter to Store procedure and when I execute it throws an error

                    Overload resolution failed because no accessible 'Parameters' accepts this number of arguments.

                    My Store procedure is

                    CREATE PROCEDURE DEVSUSH.SP_CUSTINFO (
                    IN PRMCICID INTEGER ,
                    IN PRMCIFN VARCHAR(30) ,
                    IN PRMCILN VARCHAR(30) ,
                    IN PRMCIADDR VARCHAR(90) ,
                    IN PRMCICITY VARCHAR(20) ,
                    IN PRMCISTATE VARCHAR(20) ,
                    IN PRMCIZIP NUMERIC(9, 0) ,
                    IN PRMCIPHONE NUMERIC(10, 0) ,
                    IN PRMCIEMAIL VARCHAR(30) ,
                    IN PRMCICLDATE DATE )
                    LANGUAGE SQL
                    SPECIFIC DEVSUSH.SP_CUSTINFO
                    NOT DETERMINISTIC
                    MODIFIES SQL DATA
                    CALLED ON NULL INPUT
                    SET OPTION ALWBLK = *ALLREAD ,
                    ALWCPYDTA = *OPTIMIZE ,
                    COMMIT = *NONE ,
                    DECRESULT = (31, 31, 00) ,
                    DFTRDBCOL = *NONE ,
                    DYNDFTCOL = *NO ,
                    DYNUSRPRF = *USER ,
                    SRTSEQ = *HEX
                    P1 : BEGIN
                    INSERT INTO DEVSUSH . CLCUSINF ( CICID , CIFN , CILN , CIADDR , CICITY , CISTATE , CIZIP , CIPHONE , CIEMAIL , CICLDATE ) VALUES ( @PRMCICID , @PRMCIFN , @PRMCILN , @PRMCIADDR , @PRMCICITY , @PRMCISTATE , @PRMCIZIP , @PRMCIPHONE , @PRMCIEMAIL , @PRMCICLDATE ) ;
                    END P1 ;

                    GRANT ALTER , EXECUTE
                    ON SPECIFIC PROCEDURE DEVSUSH.SP_CUSTINFO
                    TO SUSHDEV ;

                    GRANT EXECUTE
                    ON SPECIFIC PROCEDURE DEVSUSH.SP_CUSTINFO
                    TO VAIGROUP ;

                    How to solve the error?

                    Your help is much appreciated. Thanks Happy Coding!

                    G Offline
                    G Offline
                    GuyThiebaut
                    wrote on last edited by
                    #26

                    Remember, when you fix this post back under your original post with how you fixed it ;) (this can be very useful to other people who come to this forum looking for a solution to the same issue you had)

                    “That which can be asserted without evidence, can be dismissed without evidence.”

                    ― Christopher Hitchens

                    S 1 Reply Last reply
                    0
                    • G GuyThiebaut

                      Remember, when you fix this post back under your original post with how you fixed it ;) (this can be very useful to other people who come to this forum looking for a solution to the same issue you had)

                      “That which can be asserted without evidence, can be dismissed without evidence.”

                      ― Christopher Hitchens

                      S Offline
                      S Offline
                      sudevsu
                      wrote on last edited by
                      #27

                      Sure. But I didn't fix this yet.

                      Your help is much appreciated. Thanks Happy Coding!

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups