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. Web Development
  3. ASP.NET
  4. Stored Procedure OUTPUT Parameter not working.

Stored Procedure OUTPUT Parameter not working.

Scheduled Pinned Locked Moved ASP.NET
databasehelp
7 Posts 5 Posters 1 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.
  • S Offline
    S Offline
    sharad Pyakurel
    wrote on last edited by
    #1

    My method adds parameters to stored procedure as: public void AddParameter(string StrName, SqlDbType objType, ParameterDirection objDirection) { SqlParameter l_Param = new SqlParameter(); l_Param.ParameterName = StrName; l_Param.SqlDbType = objType; l_Param.Direction = objDirection; Command.Parameters.Add(l_Param); } public void AddParameter(string strName, SqlDbType objType, ParameterDirection objDirection, object objValue) { AddParameter(strName, objType, objDirection); } I have send parameters to stored procedure using above method and used ExecuteScaler and ExecuteReader both. But it displays error while executing stored procedure.

    D P S S 4 Replies Last reply
    0
    • S sharad Pyakurel

      My method adds parameters to stored procedure as: public void AddParameter(string StrName, SqlDbType objType, ParameterDirection objDirection) { SqlParameter l_Param = new SqlParameter(); l_Param.ParameterName = StrName; l_Param.SqlDbType = objType; l_Param.Direction = objDirection; Command.Parameters.Add(l_Param); } public void AddParameter(string strName, SqlDbType objType, ParameterDirection objDirection, object objValue) { AddParameter(strName, objType, objDirection); } I have send parameters to stored procedure using above method and used ExecuteScaler and ExecuteReader both. But it displays error while executing stored procedure.

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      What is the error message?

      1 Reply Last reply
      0
      • S sharad Pyakurel

        My method adds parameters to stored procedure as: public void AddParameter(string StrName, SqlDbType objType, ParameterDirection objDirection) { SqlParameter l_Param = new SqlParameter(); l_Param.ParameterName = StrName; l_Param.SqlDbType = objType; l_Param.Direction = objDirection; Command.Parameters.Add(l_Param); } public void AddParameter(string strName, SqlDbType objType, ParameterDirection objDirection, object objValue) { AddParameter(strName, objType, objDirection); } I have send parameters to stored procedure using above method and used ExecuteScaler and ExecuteReader both. But it displays error while executing stored procedure.

        P Offline
        P Offline
        Pranay Rana
        wrote on last edited by
        #3

        what is error message ?

        1 Reply Last reply
        0
        • S sharad Pyakurel

          My method adds parameters to stored procedure as: public void AddParameter(string StrName, SqlDbType objType, ParameterDirection objDirection) { SqlParameter l_Param = new SqlParameter(); l_Param.ParameterName = StrName; l_Param.SqlDbType = objType; l_Param.Direction = objDirection; Command.Parameters.Add(l_Param); } public void AddParameter(string strName, SqlDbType objType, ParameterDirection objDirection, object objValue) { AddParameter(strName, objType, objDirection); } I have send parameters to stored procedure using above method and used ExecuteScaler and ExecuteReader both. But it displays error while executing stored procedure.

          S Offline
          S Offline
          Sandeep Mewara
          wrote on last edited by
          #4

          sharad Pyakurel wrote:

          SqlParameter l_Param = new SqlParameter(); l_Param.ParameterName = StrName; l_Param.SqlDbType = objType; l_Param.Direction = objDirection; Command.Parameters.Add(l_Param);

          Looks like you forgot to add:l_Param.Value Add: l_Param.Value = objValue; You shouldn't be needing the other AddParameter method. All can be done in one.

          1 Reply Last reply
          0
          • S sharad Pyakurel

            My method adds parameters to stored procedure as: public void AddParameter(string StrName, SqlDbType objType, ParameterDirection objDirection) { SqlParameter l_Param = new SqlParameter(); l_Param.ParameterName = StrName; l_Param.SqlDbType = objType; l_Param.Direction = objDirection; Command.Parameters.Add(l_Param); } public void AddParameter(string strName, SqlDbType objType, ParameterDirection objDirection, object objValue) { AddParameter(strName, objType, objDirection); } I have send parameters to stored procedure using above method and used ExecuteScaler and ExecuteReader both. But it displays error while executing stored procedure.

            S Offline
            S Offline
            sharad Pyakurel
            wrote on last edited by
            #5

            For Parameter type Input it works perfectly. But with OUTPUT Parameter Type It Displays following Error in place of ExecuteScaler Method: String[1]: the Size property has an invalid size of 0. (Actually I have a Stored Procedure which takes @Amount as input and converts the input in word, here @word in output Parameter. It should convert input amount in word. Stored Procedure is right. but something wrong with executing from application. What should i do.

            A 1 Reply Last reply
            0
            • S sharad Pyakurel

              For Parameter type Input it works perfectly. But with OUTPUT Parameter Type It Displays following Error in place of ExecuteScaler Method: String[1]: the Size property has an invalid size of 0. (Actually I have a Stored Procedure which takes @Amount as input and converts the input in word, here @word in output Parameter. It should convert input amount in word. Stored Procedure is right. but something wrong with executing from application. What should i do.

              A Offline
              A Offline
              Arindam Tewary
              wrote on last edited by
              #6

              As per your error message , you should mention the size of outout value (irrespective of in or string whatever your output type). please give a try and let me know. As an example: if you are exptecting to get "cheers" as a word that appears from @output valiable, then mention "6" as the size of the output parameter along with itoutput parameters type.

              Thanks, Arindam D Tewary

              S 1 Reply Last reply
              0
              • A Arindam Tewary

                As per your error message , you should mention the size of outout value (irrespective of in or string whatever your output type). please give a try and let me know. As an example: if you are exptecting to get "cheers" as a word that appears from @output valiable, then mention "6" as the size of the output parameter along with itoutput parameters type.

                Thanks, Arindam D Tewary

                S Offline
                S Offline
                sharad Pyakurel
                wrote on last edited by
                #7

                Stored Procedure is executed after specifying the size of output parameter. I unable to get output parameters value as: string s=ExecuteScaler(cmd); Parameters value is not retrived in s. But if i cal using com_parameters[strParameter].value it gives value. I mean it gives single row data. How can i get OutPut parameters and other datas in tebular form, Like data returned by Select querry.

                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