ASP.NET
  Home arrow ASP.NET arrow Oracle Database Interaction Using ODP.NET ...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Moblin 
JMSL Numerical Library 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

Oracle Database Interaction Using ODP.NET and ASP.NET: All Ways to Retrieve Data
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 7
    2005-09-29

    Table of Contents:
  • Oracle Database Interaction Using ODP.NET and ASP.NET: All Ways to Retrieve Data
  • What are all of the possible ways to work with these classes?
  • Getting data with only a table name
  • Getting data with the SELECT command
  • Getting a single value from the database

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Oracle Database Interaction Using ODP.NET and ASP.NET: All Ways to Retrieve Data


    (Page 1 of 5 )

    This article mainly concentrates on retrieving data from an Oracle database with ODP.NET using ASP.NET in several possible ways.
    A downloadable file for this article is available here.

    The sample downloadable solution (zip) was entirely developed using Visual Studio.NET 2003 Enterprise Architect on Windows Server 2003 Standard Edition together with Oracle 10g (version 10.2).  But, I am confident that it would work with other versions of Windows (which support .NET 1.1) as well.

    What classes are generally used?

    My previous article mainly concentrated on connecting to an Oracle database in several possible ways.  I also introduced you the concept of ODP.NET in my previous article.  In this article I mainly concentrate on fetching information from an Oracle 10g (10.2) database using ODP.NET.

    By now, you should know that you need to work with the Oracle.DataAccess.Client namespace to use ODP.NET.  The same namespace has  several classes, collections, and enumerated types to work conveniently with both SQL and PL/SQL of the Oracle 10g product.  It even offers much tighter integration to .NET, when compared with Microsoft’s .NET provider for Oracle (System.data.OracleClient namespace).

    The most generic classes in ODP.NET to retrieve information from an Oracle database include the following:

    • OracleConnection
    • OracleCommand
    • OracleDataReader
    • OracleDataAdapter
    • OracleParameter
    • OracleParameterCollection

    Of course, any .NET data provider would provide a similar interface to the database (conforming to the standards of .NET data provider specification). The “OracleConnection” class is used to make a connection (for both dedicated or shared connections) to an Oracle database.  Without the help of the OracleConnection” class, all the rest would do nothing (because we would not be able to connect at all). 

    The “OracleCommand” class is specially used to issue a command (either SELECT or DML or to execute stored procedure and so on) to the Oracle database for some operation.  If we pass a SELECT statement (or execute a stored function returning some rows, and so forth) to an instance of the “OracleCommand” class, our application may receive some data (either in the form of rows, or a single value, or bytes, and so on).  The data, which has been returned by “OracleCommand”, can be consumed using any of the “OracleDataReader” or “OracleDataAdapter” classes.

    “OracleDataReader” is connection oriented.  It is something like a forward-only and read-only resultset.  “OracleDataAdapter” is generally used in connection-less scenarios.  Don’t confuse this with “OracleDataAdapter”, as if it could retrieve even without connecting to the database!  It indeed connects (through “OracleConnection”) to the database, passes a command (of type “OracleCommand”), fetches the information, files it into either “datatable” or “dataset” and finally breaks the “OracleConnection” itself.  “OracleDataReader”, even after fetching the data, does not break the “OracleConnection” yet (unless you “dispose” of it).

    “OracleParameter” and “OracleParameterCollection” are generally used to work with parameterized queries (or even parameterized stored procedures).  The next section gives further depth to some of the above classes in detail, so that you can select your own flexible approach based on the considerations of performance, ease, readability, re-usability, and other needs.

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · hi guys. I am ready to discuss anything here. Please also include your feedback..if...
       · how to get a persistent database connection through ASP.NET?
       · Persistant connection: Is it a connection which would never last or what? There is...
     

    ASP.NET ARTICLES

    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX
    - Building a Simple Storefront with LINQ
    - Developing a Dice Game Using ASP.NET Futures...
    - Completing an ASP.NET AJAX Server-Centric Ba...
    - Information Management for an ASP.NET AJAX S...
    - Comment and Order Management for an ASP.NET ...
    - Back-end Management Tasks for an ASP.NET AJA...
    - User Information Management for an ASP.NET A...
    - Adding Comments and Search to an ASP.NET AJA...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway