Example of Oracle using cursors to return result sets (C #)

Source: Internet
Author: User
Tags oracleconnection
oracle| samples in vs2005+oracle 92010 + Windows XP SP2 Test pass 1, create a cursor variable, use for the return value
Create or replace package types as
Type CursorType is REF CURSOR;
END;2, creating functions (or stored procedures)
Create or Replace function Testpro return types.cursortype is
LC Types.cursortype;
Begin
Open LC for SELECT * from test;
return LC;
End Testpro;3, write C # program (Note: Apply System.Data.OracleClient first)
            OracleConnection conn = new OracleConnection (" Yourconnectstring ");            OracleCommand cmd = new OracleCommand ("Testpro", conn);            cmd. CommandType = commandtype.storedprocedure;              OracleParameter op = new OracleParameter ("C", OracleType.Cursor);             op. Direction = parameterdirection.returnvalue;              CMD. Parameters.Add (OP);             DataSet ds = new DataSet ();            oracledataadapter da = new OracleDataAdapter (cmd);            &nBsp Da. Fill (ds, "test");             This.dataGridView1.DataSource = ds. tables["Test"]; PS: Using the stored procedure method is similar.


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.