1 Reply Latest reply: Feb 6, 2013 7:28 AM by Helios-GunesEROL RSS

    Unable to use ref cursor as a input parameter at the time of inserting reco


      i am unable to use ref cursor when inserting the data to oracle 11g from visual studio 2008. please help me as early as possible my code is bellows

      using System;
      using System.Collections;
      using System.Configuration;
      using System.Data;
      using System.Linq;
      using System.Web;
      using System.Web.Security;
      using System.Web.UI;
      using System.Web.UI.HtmlControls;
      using System.Web.UI.WebControls;
      using System.Web.UI.WebControls.WebParts;
      using System.Xml.Linq;
      using System.Web.Configuration;
      using Oracle.DataAccess.Client;
      using Oracle.DataAccess.Types;

      public partial class App_frmTest : System.Web.UI.Page
      protected void Page_Load(object sender, EventArgs e)

      protected void btnClick_Click(object sender, EventArgs e)
      OracleCommand cmd=new OracleCommand();
      Data objdata = new Data();
      int i = 0;
      string constr = "Data Source=Cwc;User Id=scott; Password=tiger;";// enlist=false; pooling=false;
      OracleConnection con = new OracleConnection(constr);
      /*Connection Open*/
      cmd.Connection = con;
      /*Connection Open End*/
      /*Select Through Ref Cursor*/

      cmd.CommandText = "scott.TEST_USER.getUSER";
      cmd.CommandType = CommandType.StoredProcedure;
      OracleParameter p_rc = cmd.Parameters.Add("p_rc", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Output);
      OracleParameter p_rc1;
      if (TextBox1.Text == "")
      p_rc1 = cmd.Parameters.Add("p_rc", OracleDbType.Int16, DBNull.Value, ParameterDirection.Input);
      p_rc1 = cmd.Parameters.Add("p_rc", OracleDbType.Int16, Convert.ToInt16(TextBox1.Text), ParameterDirection.Input);
      // OracleParameter p_rc1 = cmd.Parameters.Add("p_rc", OracleDbType.Int16, 2, ParameterDirection.Input);
      OracleDataReader reader = cmd.ExecuteReader();

      DataSet ds = new DataSet();
      DataTable dt1 = new DataTable();
      GridView1.DataSource = ds;


      OracleCommand cmd1 = new OracleCommand();
      OracleConnection con1 = new OracleConnection(constr);
      cmd1.Connection = con1;

      cmd1.CommandText = "scott.TEST_USER.ADDUSER";
      cmd1.CommandType = CommandType.StoredProcedure;

      OracleParameter P_ADDUSER = cmd1.Parameters.Add("P_ADDUSER", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Input);

      cmd1.ExecuteNonQuery(); // i am getting error when executing this line



      Server Error in '/CWC' Application.

      Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
      Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

      Exception Details: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

      Source Error: 

      Line 77: OracleParameter P_ADDUSER = cmd1.Parameters.Add("P_ADDUSER", OracleDbType.RefCursor, DBNull.Value, ParameterDirection.Input);
      Line 78: //OracleParameter P_MSG = cmd.Parameters.Add("P_MSG", OracleDbType.Varchar2, DBNull.Value, ParameterDirection.Output);
      Line 79: cmd1.ExecuteNonQuery();
      Line 80:
      Line 81: DataTable dt = new DataTable();

      Source File: d:\CWC\App\frmTest.aspx.cs    Line: 79 

      Stack Trace: 

      [AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
      Oracle.DataAccess.Client.OpsSql.ExecuteNonQuery(IntPtr opsConCtx, IntPtr& opsErrCtx, IntPtr& opsSqlCtx, IntPtr& opsDacCtx, IntPtr opsSubscrCtx, Int32& isSubscrRegistered, Int32 bchgNTFNExcludeRowidInfo, Int32 bQueryBasedNTFNRegistration, Int64& query_id, OpoSqlValCtx*& pOpoSqlValCtx, String pCommandText, IntPtr& pUTF8CommandText, IntPtr[] pOpoPrmValCtx, String[] ppOpoPrmRefCtx, OpoMetValCtx*& pOpoMetValCtx, Int32 prmCnt, Int32 bFromPool) +0
      Oracle.DataAccess.Client.OracleCommand.ExecuteNonQuery() +4731
      App_frmTest.btnClick_Click(Object sender, EventArgs e) in d:\CWC\App\frmTest.aspx.cs:79
      System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
      System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
      System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
      System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
      System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
      System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565