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. General Programming
  3. C#
  4. Oracle stored procedure call in C#

Oracle stored procedure call in C#

Scheduled Pinned Locked Moved C#
databasecsharporaclewpfwcf
6 Posts 2 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.
  • S Offline
    S Offline
    sampath_dr
    wrote on last edited by
    #1

    Hi..i'm write following pl sql procedure to save data record.i have created a table called SETUP_TAB. i want to add to data from a datagridview in a form.can anyone please tell me how to do it. PROCEDURE Insert___ ( id_ OUT VARCHAR2, version_ OUT VARCHAR2, rec_ IN OUT SETUP_TAB%ROWTYPE, attribute_ IN OUT VARCHAR2 ) i have write following C# code also.but it gives "Invalid parameter binding" exception. OracleConnection conn = new OracleConnection(); String str = "Data source=****;user ID=****;Password=****;"; conn.ConnectionString = str; OracleCommand cmd = new OracleCommand("PROJX_INTEGRATION_SETUP.Insert___",conn); cmd.CommandType = CommandType.StoredProcedure; OracleParameter datarow = new OracleParameter(); datarow.ParameterName = "newrec_"; datarow.OracleDbType = OracleDbType.Raw; datarow.Direction = ParameterDirection.InputOutput; datarow.Value = this.dataGridView1.Rows[0]; cmd.Parameters.Add(datarow); OracleParameter attr = new OracleParameter(); attr.ParameterName = "attr_"; attr.OracleDbType = OracleDbType.Varchar2; attr.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(attr); OracleParameter o1 = new OracleParameter(); o1.ParameterName = "objid_"; o1.OracleDbType = OracleDbType.Varchar2; o1.Direction = ParameterDirection.Output; cmd.Parameters.Add(o1); OracleParameter o2 = new OracleParameter(); o2.ParameterName = "objversion_"; o2.OracleDbType = OracleDbType.Varchar2; o2.Direction = ParameterDirection.Output; cmd.Parameters.Add(o2); try { conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } catch (OracleException ex) { MessageBox.Show(ex.Message, "Oracle Exception"); }

    N 1 Reply Last reply
    0
    • S sampath_dr

      Hi..i'm write following pl sql procedure to save data record.i have created a table called SETUP_TAB. i want to add to data from a datagridview in a form.can anyone please tell me how to do it. PROCEDURE Insert___ ( id_ OUT VARCHAR2, version_ OUT VARCHAR2, rec_ IN OUT SETUP_TAB%ROWTYPE, attribute_ IN OUT VARCHAR2 ) i have write following C# code also.but it gives "Invalid parameter binding" exception. OracleConnection conn = new OracleConnection(); String str = "Data source=****;user ID=****;Password=****;"; conn.ConnectionString = str; OracleCommand cmd = new OracleCommand("PROJX_INTEGRATION_SETUP.Insert___",conn); cmd.CommandType = CommandType.StoredProcedure; OracleParameter datarow = new OracleParameter(); datarow.ParameterName = "newrec_"; datarow.OracleDbType = OracleDbType.Raw; datarow.Direction = ParameterDirection.InputOutput; datarow.Value = this.dataGridView1.Rows[0]; cmd.Parameters.Add(datarow); OracleParameter attr = new OracleParameter(); attr.ParameterName = "attr_"; attr.OracleDbType = OracleDbType.Varchar2; attr.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(attr); OracleParameter o1 = new OracleParameter(); o1.ParameterName = "objid_"; o1.OracleDbType = OracleDbType.Varchar2; o1.Direction = ParameterDirection.Output; cmd.Parameters.Add(o1); OracleParameter o2 = new OracleParameter(); o2.ParameterName = "objversion_"; o2.OracleDbType = OracleDbType.Varchar2; o2.Direction = ParameterDirection.Output; cmd.Parameters.Add(o2); try { conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); } catch (OracleException ex) { MessageBox.Show(ex.Message, "Oracle Exception"); }

      N Offline
      N Offline
      N a v a n e e t h
      wrote on last edited by
      #2

      Parameter names in your procedure and OracleParameter instance should match. Also you need to preserve the order in which parameters are added.

      Navaneeth How to use google | Ask smart questions

      S 1 Reply Last reply
      0
      • N N a v a n e e t h

        Parameter names in your procedure and OracleParameter instance should match. Also you need to preserve the order in which parameters are added.

        Navaneeth How to use google | Ask smart questions

        S Offline
        S Offline
        sampath_dr
        wrote on last edited by
        #3

        thank you for reply my post.i have done that in your way.but still it gives following exception. :( :confused: "Invalid parameter binding Parameter name: rec_" here is my modified code. OracleParameter rec_ = new OracleParameter(); rec_.ParameterName = "rec_"; rec_.OracleDbType = OracleDbType.Raw; rec_.Direction = ParameterDirection.InputOutput; rec_.Value = this.dataGridView1.Rows[0]; cmd.Parameters.Add(rec_);

        N 1 Reply Last reply
        0
        • S sampath_dr

          thank you for reply my post.i have done that in your way.but still it gives following exception. :( :confused: "Invalid parameter binding Parameter name: rec_" here is my modified code. OracleParameter rec_ = new OracleParameter(); rec_.ParameterName = "rec_"; rec_.OracleDbType = OracleDbType.Raw; rec_.Direction = ParameterDirection.InputOutput; rec_.Value = this.dataGridView1.Rows[0]; cmd.Parameters.Add(rec_);

          N Offline
          N Offline
          N a v a n e e t h
          wrote on last edited by
          #4

          As I said, parameters should be in the order which they have written in the procedure. So first id_ then version_ etc should come. rec_ should be the 3rd parameter.

          Navaneeth How to use google | Ask smart questions

          S 1 Reply Last reply
          0
          • N N a v a n e e t h

            As I said, parameters should be in the order which they have written in the procedure. So first id_ then version_ etc should come. rec_ should be the 3rd parameter.

            Navaneeth How to use google | Ask smart questions

            S Offline
            S Offline
            sampath_dr
            wrote on last edited by
            #5

            yes..i have done that way..but still it gives same result.:confused: PROCEDURE Insert___ ( id_ OUT VARCHAR2, version_ OUT VARCHAR2, rec_ IN OUT PROJX_INTEGRATION_SETUP_TAB%ROWTYPE, attribute_ IN OUT VARCHAR2 ) =========================================================== OracleParameter id_ = new OracleParameter(); id_.ParameterName = "id_"; id_.OracleDbType = OracleDbType.Varchar2; id_.Direction = ParameterDirection.Output; cmd.Parameters.Add(id_); OracleParameter version_ = new OracleParameter(); version_.ParameterName = "version_"; version_.OracleDbType = OracleDbType.Varchar2; version_.Direction = ParameterDirection.Output; cmd.Parameters.Add(version_); OracleParameter rec_ = new OracleParameter(); rec_.ParameterName = "rec_"; rec_.OracleDbType = OracleDbType.Raw; rec_.Direction = ParameterDirection.InputOutput; rec_.Value = this.dataGridView1.Rows[0]; cmd.Parameters.Add(rec_); OracleParameter attribute_ = new OracleParameter(); attribute_.ParameterName = "attribute_"; attribute_.OracleDbType = OracleDbType.Varchar2; attribute_.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(attribute_);

            S 1 Reply Last reply
            0
            • S sampath_dr

              yes..i have done that way..but still it gives same result.:confused: PROCEDURE Insert___ ( id_ OUT VARCHAR2, version_ OUT VARCHAR2, rec_ IN OUT PROJX_INTEGRATION_SETUP_TAB%ROWTYPE, attribute_ IN OUT VARCHAR2 ) =========================================================== OracleParameter id_ = new OracleParameter(); id_.ParameterName = "id_"; id_.OracleDbType = OracleDbType.Varchar2; id_.Direction = ParameterDirection.Output; cmd.Parameters.Add(id_); OracleParameter version_ = new OracleParameter(); version_.ParameterName = "version_"; version_.OracleDbType = OracleDbType.Varchar2; version_.Direction = ParameterDirection.Output; cmd.Parameters.Add(version_); OracleParameter rec_ = new OracleParameter(); rec_.ParameterName = "rec_"; rec_.OracleDbType = OracleDbType.Raw; rec_.Direction = ParameterDirection.InputOutput; rec_.Value = this.dataGridView1.Rows[0]; cmd.Parameters.Add(rec_); OracleParameter attribute_ = new OracleParameter(); attribute_.ParameterName = "attribute_"; attribute_.OracleDbType = OracleDbType.Varchar2; attribute_.Direction = ParameterDirection.InputOutput; cmd.Parameters.Add(attribute_);

              S Offline
              S Offline
              sampath_dr
              wrote on last edited by
              #6

              I have sorted out my problem.thanks for all , special thank for "navaneeth" ... :laugh: :laugh:

              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