Solved

c# parameter of type cursor

Posted on 2010-09-13
8
522 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
  • 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
 

Author Comment

by:enrique_aeo
ID: 33667361
is exactly what I'm doing, I would not recommend?
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 16

Accepted Solution

by:
SriVaddadi earned 250 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 250 total points
ID: 33667393
sorry, my bad
  if ((con != null) && (con.State != ConnectionState.Closed))      
            con.Close();
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now