Results 1 to 2 of 2

Thread: [2.0] How to call oracle stored procedure from C#?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Oct 2003
    Posts
    436

    [2.0] How to call oracle stored procedure from C#?

    If any body has some good links (examples), please post. I have oracle procedure. I would like to call that proc and capture results in a dataset and display in the grid.

    thanks
    nath

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2.0] How to call oracle stored procedure from C#?

    One of the good things about ADO.NET is that it is basically no different regardless of your data source. If you know how to call a sproc in SQL Server then you know how to do it in Oracle. You create a comand of the appropriate type, set its CommandType to StoredProcedure and its CommandText to the name of the sproc. In your case it will be an OracleCommand, e.g.
    Code:
    OracleConnection connection = new OracleConnection("connection string here");
    OracleDataAdapter adapter = new OracleDataAdapter("sproc name here", connection);
    
    adapter.SelectCommand.CommandType = CommandType.StoredProcedure;
    
    DataTable table = new DataTable;
    
    adapter.Fill(table);
    grid.DataSource = table;
    This is exactly as it would be for SQL Server except everything begins with "Oracle" instead of "Sql". The implication is that ANY ADO.NET information is useful because all you have to do is change the data namespace and the corresponding types and it will work essentially "as is". There is plenty of information around for using ADO.NET, particularly with SQL Server.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width