Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

c# parameter of type cursor

Posted on 2010-09-13
8
Medium Priority
?
635 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

609 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