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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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: 4 stars4 stars4 stars4 stars4 stars / 13
    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

    - Adding Content to a Static ASP.NET Website
    - Building a Static ASP.NET Website in a Basic...
    - Develop Your First ASP.NET Website with Visu...
    - Run ASP.NET in Windows XP Home with Cassini ...
    - How to Test a Web Application
    - How to Add Code and Validation Controls to a...
    - Working in Source and Split Views to Build a...
    - How to Build a Web Form for a One-Page Web A...
    - How to Develop a One-Page Web Application
    - An ASP.NET Web Application in Action
    - Developing ASP.NET Web Applications
    - An Introduction to ASP.NET Web Programming
    - Introduction to the ADO.NET Entity Framework...
    - Completing an In-Text Advertising System und...
    - Programming an In-Text Advertising System un...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek