Posted By

rengber on 07/25/06


Tagged

Net Oracle PLSQL StoredProc ODPNet Winform


Versions (?)

Oracle Stored Proc to Return a Recordset (.Net Side)


 / Published in: C#
 

Very important to set the RefCursor Type. Otherwise you get the PLS-00306 Error 'Wrong Number or types of arguments'

  1. Oracle.DataAccess.Client.OracleConnection OraConn = new Oracle.DataAccess.Client.OracleConnection();
  2. OraConn.ConnectionString = "Data Source=DBName;User Id=MyUser;Password=MyPW;";
  3. OraConn.Open();
  4. Oracle.DataAccess.Client.OracleCommand OraComm = new Oracle.DataAccess.Client.OracleCommand("RobCursorTestProc", OraConn);
  5. OraComm.CommandType = CommandType.StoredProcedure;
  6. OraComm.Parameters.Add("Cursor", Oracle.DataAccess.Client.OracleDbType.RefCursor, ParameterDirection.Output);
  7. Oracle.DataAccess.Client.OracleDataReader OraDR = OraComm.ExecuteReader();
  8. if (OraDR.Read())
  9. {
  10. MessageBox.Show(OraDR.GetName(0));
  11. MessageBox.Show(OraDR.GetValue(0).ToString());
  12. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: ixia on February 7, 2008

you should put your OraConn object in a using() statement to make sure it get s closed...

You need to login to post a comment.