Solved

Binding winform listbox to oracle ref cursor

Posted on 2009-05-04
5
672 Views
Last Modified: 2013-12-18
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=;");

            Oraclecon.Open();
 

            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);

            adapter.Fill(ds);

            

            this.lstActiveClients.DataSource = ds;

            this.lstActiveClients.DisplayMember = "name";

            this.lstActiveClients.ValueMember = "client_key";

Open in new window

0
Comment
Question by:michael1174
  • 3
  • 2
5 Comments
 
LVL 8

Expert Comment

by:RyanAndres
ID: 24297964
Please post any errors you received.
0
 
LVL 2

Author Comment

by:michael1174
ID: 24298060
I'm getting a wrong number or types of arguments to client_find when it executes the adapter.Fill(ds);
0
 
LVL 2

Author Comment

by:michael1174
ID: 24298087
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
0
 
LVL 8

Accepted Solution

by:
RyanAndres earned 500 total points
ID: 24298129
You need to assign the datasource a datatable or object collection.
this.lstActiveClients.DataSource = ds.Table[0];
0
 
LVL 2

Author Closing Comment

by:michael1174
ID: 31577673
Thanks!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…

948 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

18 Experts available now in Live!

Get 1:1 Help Now