.NET
  Home arrow .NET arrow Page 5 - .NET Stored Proceedures: Reading Excel Fil...
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 
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? 
.NET

.NET Stored Proceedures: Reading Excel Files or Transferring SQL Server Tables into Oracle Tables
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 31
    2006-01-03

    Table of Contents:
  • .NET Stored Proceedures: Reading Excel Files or Transferring SQL Server Tables into Oracle Tables
  • Developing an Oracle based .NET CLR stored procedure using Visual Studio.NET
  • Understanding the .NET CLR Stored Procedure (working with Excel)
  • Deploying and testing Oracle based .NET CLR stored procedure using Visual Studio.NET
  • Understanding the .NET CLR Stored Procedure (working with SQL Server 2000 table)

  • 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


    .NET Stored Proceedures: Reading Excel Files or Transferring SQL Server Tables into Oracle Tables - Understanding the .NET CLR Stored Procedure (working with SQL Server 2000 table)


    (Page 5 of 5 )

    In the previous section, I explained how to work with Excel.  Now, I would like to change my direction from Excel to SQL Server 2000.  This means that now we shall transfer rows from SQL Server 2000 table to an Oracle Table using the .NET stored procedure in Oracle. 

    The following is the code to accomplish this task:

    Public Shared Sub ReadSQL()
            Dim sqlconn As New SqlConnection("data source=pc2;initial
    catalog=northwind;user id=sa"
    )
            Dim sqlda As New SqlDataAdapter("select * from
    [tempemp]"
    , sqlconn)
            Dim sqldt As New DataTable
            sqlda.Fill(sqldt)
            sqlda.Dispose()
            sqlconn.Close()
     
            Dim conn As New OracleConnection("context
    connection=true"
    )
            Dim da As New OracleDataAdapter("select * from
    scott.tempemp"
    , conn)
            Dim cb As OracleCommandBuilder = New OracleCommandBuilder
    (da)
            Dim ds As New DataSet
            da.Fill(ds, "tempemp")
     
            For Each xlrow As DataRow In sqldt.Rows
                Dim dr As DataRow = ds.Tables("tempemp").NewRow
                For Each col As DataColumn In ds.Tables
    ("tempemp").Columns
                    dr(col.ColumnName) = xlrow(col.ColumnName)
                Next
                ds.Tables("tempemp").Rows.Add(dr)
            Next
            da.Update(ds, "tempemp")
            da.Dispose()
            conn.Close()
        End Sub

    The above stored procedure directly connects to SQL Server 2000 with the help of the “.NET SQL Client provider.”  The rest of this part is quite similar.

    To know and work with “OracleConnection”, “OracleCommand” and other objects, I suggest you go through my series on “ODP.NET with ASP.NET” within the same website.  Other enhancements to this solution would be something like “sending the filename as parameter,” “working with multiple columns,” “working with delimiters,” and so on.  You can download the entire source code (Visual studio.NET) solution at the beginning of this article.  I leave it to the programmers for further enhancements. Any doubts, comments, suggestions, bugs, errors or feedback are welcomed at jag_chat@yahoo.com 


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Now I contributed .NET stored procedure to read and transfer Excel files and SQL...
       · i've used your third page information to insert records from excel into oracle db,...
       · Even though, I could not get a proper solution for your problem, I can provide you...
       · Sorry for troubling...I think i found the rootcause - my memory control...
       · Hai,I am very happy that you could find the root of your problem. In fact, your...
       · Hi,I have used your code example to export data from an Excel spreadsheet and...
     

    .NET ARTICLES

    - Using CrystalReportViewer to Display Crystal...
    - Creating Summary .Net Crystal Reports
    - More on Commands, Input and the WPF
    - Grouping and Aggregating When Querying LINQ ...
    - Commands, Input and the WPF
    - Keyboard and Ink Input with WPF
    - Mouse Input and the WPF
    - Input with Windows Presentation Foundation
    - Introducing LINQ with XML and Databases
    - An Introduction to LINQ
    - Querying LINQ to SQL: Basics
    - Completing a Simple Storefront with LINQ
    - Knowing Your Environment: the System.Environ...
    - Creating the Home Page for a Simple Storefro...
    - LINQ Quickly with Language Integrated Queries





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