Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Binding winform listbox to oracle ref cursor

Posted on 2009-05-04
5
Medium Priority
?
682 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
[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
  • 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 2000 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to take different types of Oracle backups using RMAN.

721 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