?
Solved

c# parameter of type cursor

Posted on 2010-09-13
8
Medium Priority
?
619 Views
Last Modified: 2012-05-10
Hi experts, i have this package in oracle
CREATE OR REPLACE PACKAGE pckCurso AS
      
  PROCEDURE upCursosHabilitadosPAPws(pCursor    OUT mGeneric);

as I call it from. net is considering a parameter of type cursor?

Can you help me modify this code? or have any better
public DataSet MostrarCursosHabilitadosPAP()
        {
            OracleConnection con;
            OracleCommand cmd;
            OracleDataAdapter adpt;
            DataSet ds = new DataSet();
            string SP = "pckCurso.upCursosHabilitadosPAPws";
            con = new OracleConnection(ConfigurationManager.ConnectionStrings["bdradesanewConnectionString"].ConnectionString);
            cmd = new OracleCommand(SP, con);
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add("@numdle", SqlDbType.NChar, 16).Value = numeroDocumento;
            adpt = new OracleDataAdapter(cmd);
            con.Open();
            adpt.Fill(ds);
            con.Close();
            return ds;
        }
0
Comment
Question by:enrique_aeo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
8 Comments
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 33667340

public DataSet MostrarCursosHabilitadosPAP()
        {
            OracleConnection con;
            OracleCommand cmd;
            OracleDataAdapter adpt;
            DataSet ds = new DataSet();
            string SP = "pckCurso.upCursosHabilitadosPAPws";
            con = new OracleConnection(ConfigurationManager.ConnectionStrings["bdradesanewConnectionString"].ConnectionString);
            cmd = new OracleCommand(SP, con);
            cmd.CommandType = CommandType.StoredProcedure;
OracleParameter[] parameters = new OracleParameter[2];
parameter[0] = new OracleParameter("@numdle", OracleType.NChar, 16);
parameter[0].Direction = ParameterDirection.Input;
parameter[0].Value = numeroDocumento;
parameter[1] = new OracleParameter("@numdle", OracleType.Cursor);
parameter[1].Direction = ParameterDirection.Output;            
cmd.Parameters.AddRange(parameters);
adpt = new OracleDataAdapter(cmd);
            con.Open();
            adpt.Fill(ds);
            con.Close();
            return ds;
        }
0
 

Author Comment

by:enrique_aeo
ID: 33667349
this is the code, it is work
public DataSet MostrarCursosHabilitadosPAP()
        {
            OracleConnection con;
            OracleCommand cmd;
            OracleDataAdapter adpt;
            DataSet ds = new DataSet();
            string SP = "pckCurso.upCursosHabilitadosPAPws";
            con = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleDesa"].ConnectionString);

            try
            {
                cmd = new OracleCommand(SP, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("pCursor", OracleType.Cursor).Direction = ParameterDirection.Output;
                adpt = new OracleDataAdapter(cmd);
                con.Open();
                adpt.Fill(ds);
                con.Close();
                return ds;
            }
            catch (Exception ex)
            {
               
                throw ex;
            }
           
        }

can be improved using a finally???
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 33667351
One more thing. You are trying to populate dataset. I hope you are NOT trying to populate the dataset with the output cursor.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:enrique_aeo
ID: 33667361
is exactly what I'm doing, I would not recommend?
0
 
LVL 16

Accepted Solution

by:
SriVaddadi earned 1000 total points
ID: 33667368
public DataSet MostrarCursosHabilitadosPAP()
        {
            OracleConnection con;
            OracleCommand cmd;
            OracleDataAdapter adpt;
            DataSet ds = new DataSet();
            string SP = "pckCurso.upCursosHabilitadosPAPws";
            con = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleDesa"].ConnectionString);

            try
            {
                cmd = new OracleCommand(SP, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add("pCursor", OracleType.Cursor).Direction = ParameterDirection.Output;
                adpt = new OracleDataAdapter(cmd);
                con.Open();
                adpt.Fill(ds);


            }
            catch (Exception ex)
            {
               
                throw ex;
            }
finally
{
adpt = null;
       cmd = null;
         if ((con != null) && (con.State != con.Closed))      
            con.Close();
      con = null;
}
                return ds;
           
        }
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 33667378
I was of a different understanding from your first snippet of code .. if your code works then its fine.
0
 

Author Comment

by:enrique_aeo
ID: 33667385
i have this error
Error 1 'System.Data.OracleClient.OracleConnection' does not contain a definition of 'Closed' or found no extension method 'Closed' accepting a first argument of type 'System.Data.OracleClient.OracleConnection' (missing a directive use or an assembly reference?) C: \ Users \ elopez \ Documents \ AMAG \ slnWSExcelInscritos \ wsConsultarInscripciones \ consultar.asmx.cs 54 56 wsConsultarInscripciones
0
 
LVL 16

Assisted Solution

by:SriVaddadi
SriVaddadi earned 1000 total points
ID: 33667393
sorry, my bad
  if ((con != null) && (con.State != ConnectionState.Closed))      
            con.Close();
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question