Query Result

by Ruben 3/26/2008 2:03:00 AM

The .NET Framework 2.0 introduces a very handy new class in the System.Data.SqlClient namespace called SqlBulkCopy that makes it very easy and efficient to copy large amounts of data from your .NET applications to a SQL Server database. Transfering data from one source to another is a common practice in software development. This operation is preformed in many different scenarios which includes migration of the old system to the new system, backing up the data. VB.NET 2.0 includes the SqlBulkCopy class that helps to copy the data from different data sources to SQL SERVER database.

See my sample Query Result that copy the record set to other table with same database structure using class SQLBulkCopy.

Public Sub SqlCopyDataRow(ByVal SQLquery As String, ByVal dbConnection As String, _
       ByVal TableName As String, ByVal ServerName As String, ByVal dbSchema As String)
   Try
       Dim otable As DataTable = clsDbConnection.ExecuteTable(dbConnection, CommandType.Text, SQLquery)
       Dim reader As New DataTableReader(otable)

       Dim sbc As SqlBulkCopy = New SqlBulkCopy("server=" & ServerName & "; database=" & _
           dbSchema & ";Password=+xxxxxx+; User ID=sa")
       sbc.DestinationTableName = TableName
       sbc.WriteToServer(reader)
       sbc.Close()
       reader.Close()
    Catch ex As Exception
       MessageBox.Show(ex.Message, "S2xDE", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Try
End Sub

using the procedure SqlCopyDataRow
SqlCopyDataRow("SELECT * FROM e1 WHERE ba_no = '" & gsBatchNo & "'", clsDbConnection.ConnProcess & _
    "RES-1900", "co_e1", gsServerLocation, "RES-1900")

FREE PDF BOOK DOWNLOAD

Related posts

Comments

3/27/2008 3:51:49 AM

pingback

Pingback from juansite.free-site-host.com

application servers

juansite.free-site-host.com

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

9/7/2008 5:27:18 AM

Recieved Updates



Enter your email address:

Delivered by FeedBurner

About the author

Name of author RUBEN CORRAL
System Developer in outSourcing company for almost 8 years. I built this blogs just for fun, sharing idea's, contribute a piece of code, especially to newbie programmers.

E-mail me Send mail

Calendar

<<  September 2008  >>
MoTuWeThFrSaSu
25262728293031
1234567
891011121314
15161718192021
22232425262728
293012345

View posts in large calendar

Disclaimer

The opinions expressed herein are my own personal point of view. Sample source codes are free to modify or enhance for your own satisfaction.

Sign in

All brand names, logos and trademarks in this site are property of their respective owners.