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 
Mobile Linux 
App Generation ROI 
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 Manipulate Data Continued
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 11
    2005-10-20

    Table of Contents:
  • Oracle Database Interaction Using ODP.NET and ASP.NET: All Ways to Manipulate Data Continued
  • Multiple DML commands with Array Binding – Method 1
  • Multiple DML commands with Array Binding – Method 2
  • Using Dataset for automatic updating
  • Using Dataset for automatic updating using command parameters
  • A beautiful tip when manipulating with “OracleCommand”

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


    (Page 1 of 6 )

    This article (part five of this series) is an extension to my previous article “All Possible ways to Manipulate Data,” which covered manipulating data in 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) is 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.

    Multiple DML commands with parameters: Method 2

    In my previous article I already explained a few of the methods used to manipulate information in an Oracle database.  In this article, we try to cover the rest of the methodologies.  The previous article ended with “Multiple DML commands with parameters: Method 1.”  Here we examine “method 2.”

    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.Connection = cn
                cmd.Connection.Open()
                cmd.CommandText = "insert into emp
    (empno,ename,sal,deptno) values (:empno,:ename,:sal,:deptno)"
                cmd.Parameters.Add("empno", 1111)
                cmd.Parameters.Add("ename", "jag")
                cmd.Parameters.Add("sal", 4500)
                cmd.Parameters.Add("deptno", 40)
                cmd.ExecuteNonQuery()

                cmd.Parameters.Clear()
                cmd.Parameters.Add("empno", 2222)
                cmd.Parameters.Add("ename", "win")
                cmd.Parameters.Add("sal", 2300)
                cmd.Parameters.Add("deptno", 40)
                cmd.ExecuteNonQuery()

                cmd.Parameters.Clear()
                cmd.Parameters.Add("empno", 3333)
                cmd.Parameters.Add("ename", "dhan")
                cmd.Parameters.Add("sal", 3400)
                cmd.Parameters.Add("deptno", 40)
                cmd.ExecuteNonQuery()

                cmd.Dispose()
                Me.lblError.Text = "Succesfully inserted.."
            Catch ex As Exception
                Me.lblError.Text = ex.Message
           
    Finally
                If cn.State = ConnectionState.Open
    Then
                    cn.Close()
               
    End If
            End Try

    This method is very similar to the one provided in my previous article.  But here, I excluded all the formalities of creating separate “OracleCommand” objects and simplified the matter.  Actually it is unnecessary to create “OracleCommand” for every scenario. 

    If you would like to cast your values in a very proper (strict) manner, then it would help you.  In other words, ODP.NET is intelligent enough to create its own “OracleCommand” objects, even if you provide the parameters using the above syntax.  You can save a lot of statements using this method! 

    More ASP.NET Articles
    More By Jagadish Chaterjee


       · I extended my previous article to further provide few more choices....have a...
     

    ASP.NET ARTICLES

    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - 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...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT