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 Continued
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2005-10-06

    Table of Contents:
  • Oracle Database Interaction Using ODP.NET and ASP.NET: All Ways to Retrieve Data Continued
  • Multiple Parameterized queries
  • Making an offline (connectionless) cache using “OracleDataReader”
  • Making an offline cache using “OracleDataAdapter”
  • Parameterized queries using “OracleDataAdapter”

  • 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 Continued


    (Page 1 of 5 )

    This article (part three of this series) is an extension to my previous article “All Possible ways to retrieve data” 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.

    Single Parameterized queries

    In my previous article I explained a few of the methods to retrieve information from an Oracle database.  In this article, we try to cover the rest of the methodologies.  One of them is “Single Parameterized Queries.” 

    Let us consider the following example:

    Dim cn As New OracleConnection("User ID=scott;password=tiger;Data
    Source=ORCL")
           
    Try
                Dim cmd As New OracleCommand
                cmd.CommandText = "select * from emp where deptno
    = :p_deptno"
                cmd.CommandType = CommandType.Text
                cmd.Connection = cn
                Dim pr_deptno As New OracleParameter
                pr_deptno.ParameterName = "p_deptno"
                pr_deptno.OracleDbType = OracleDbType.Int16
                pr_deptno.Value = Convert.ToInt16("10")
                cmd.Parameters.Add(pr_deptno)
                cmd.Connection.Open()
                Me.DataGrid1.DataSource = cmd.ExecuteReader
                Me.DataGrid1.DataBind()
                cmd.Dispose()
            Catch ex As Exception
                Me.lblError.Text = ex.Message
           
    Finally
                If cn.State = ConnectionState.Open
    Then
                    cn.Close()
               
    End If
            End Try

    From the above example, let us consider only the differential changes from previous methodologies.  Let us consider the following statement:

    cmd.CommandText = "select * from emp where deptno = :p_deptno"

    We can understand the entire SELECT statement except “:p_deptno”.  It is called as a parameter within the SELECT query.  A parameter could be any name but should be preceded with a colon.  We provide a value for that parameter by using a separate class, “OracleParameter,” as shown in the following:

    Dim pr_deptno As New OracleParameter
    pr_deptno.ParameterName = "p_deptno"
    pr_deptno.OracleDbType = OracleDbType.Int16
    pr_deptno.Value = Convert.ToInt16("10")

    Finally, we add the parameter value (or the instance of OracleParameter) to the “OracleCommand” object and then execute it as shown in the following:

    cmd.Parameters.Add(pr_deptno)
    cmd.Connection.Open()
    Me.DataGrid1.DataSource = cmd.ExecuteReader
    Me.DataGrid1.DataBind()
    cmd.Dispose()

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · Hai guys....can u find all the best ways to to retrieve Oracle data using ODP.NET...
     

    ASP.NET ARTICLES

    - 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...
    - Order-Related Modules for an ASP.NET AJAX Se...





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