• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 694
  • Last Modified:

Binding winform listbox to oracle ref cursor

I'm trying to bind a oracle stored procedure to a listbox using .net c# winform. Can someone tell me what I'm doing wrong?

My oracle SP is defined as:
    PROCEDURE client_find
            ( p_client_name IN client.name%TYPE
            , p_last_trade_date IN client.last_trade_date%TYPE
            , p_is_active IN client.is_active%TYPE
            , io_cursor IN OUT t_cursor)

OracleConnection Oraclecon = new OracleConnection("Password=;" + "User ID=;Data Source=;");
            OracleCommand myCMD = new OracleCommand();
            myCMD.Connection = Oraclecon;
            myCMD.CommandText = "client_select.client_find";
            myCMD.CommandType = CommandType.StoredProcedure;
            myCMD.Parameters.Add("p_client_name", OracleType.NVarChar).Value = null;
            myCMD.Parameters.Add("p_last_trade_date", OracleType.DateTime).Value = DateTime.Now.ToString("dd/MM/yyyy");
            myCMD.Parameters.Add("p_is_active", OracleType.Int16).Value = -1;
            myCMD.Parameters.Add(new OracleParameter("io_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output;
            DataSet ds = new DataSet();
            OracleDataAdapter adapter = new OracleDataAdapter(myCMD);
            this.lstActiveClients.DataSource = ds;
            this.lstActiveClients.DisplayMember = "name";
            this.lstActiveClients.ValueMember = "client_key";

Open in new window

  • 3
  • 2
1 Solution
Please post any errors you received.
michael1174Author Commented:
I'm getting a wrong number or types of arguments to client_find when it executes the adapter.Fill(ds);
michael1174Author Commented:
Ok, i had the name set to null... i fixed that, but now my listbox doesn't show any data from the SP.  It just shows one line that says System.Data.DataViewManagerListItemTypeDescriptor
You need to assign the datasource a datatable or object collection.
this.lstActiveClients.DataSource = ds.Table[0];
michael1174Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now