by Gehan Fernando. (13 Submissions)
Category: Databases/Data Access/DAO/ADO
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Wed 26th September 2007
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Use SQLBulkCopy Method To Transfer Data ...... This Is Use To Hundred Thousand Data In Several Seconds. With Progress Feature.
API Declarations
.SqlClient
Private Rcount As Long = 0
Private Sub ButtonBulkCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonBulkCopy.Click
Dim Scon As New SqlConnection("Data Source=MYPC;Initial Catalog=MyTest;Integrated Security=True")
Scon.Open()
Dim Scom As New SqlCommand("SELECT COUNT(*) FROM BulkData", Scon)
Rcount = Convert.ToInt32(Scom.ExecuteScalar())
LabelCounting.Text = "Starting Row Count :- " & Rcount
LabelCounting.Refresh()
With ProgressBarSQL
.Minimum = 0
.Maximum = Rcount
.Value = 0
End With
Scom.Cancel() : Scom.Dispose()
Scom = New SqlCommand("SELECT ItemNo,BulkItemName,BulkTime FROM BulkData ORDER BY ItemNo", Scon)
Dim Rdr As SqlDataReader = Scom.ExecuteReader()
Dim BulkCopy As New SqlBulkCopy("Data Source=MYPC;Initial Catalog=MyTest;Integrated Security=True")
BulkCopy.DestinationTableName = "BackupBulkData"
AddHandler BulkCopy.SqlRowsCopied, AddressOf OnSQLRowCopied
BulkCopy.NotifyAfter = 50
Try
BulkCopy.WriteToServer(Rdr)
Catch ex As Exception
MessageBox.Show(ex.Message)
Finally
Rdr.Close()
End Try
End Sub
Private Sub OnSQLRowCopied(ByVal sender As Object, ByVal e As SqlRowsCopiedEventArgs)
LabelCounting.Text = "Copied Data So Far :- " & e.RowsCopied
LabelCounting.Refresh()
ProgressBarSQL.Value = e.RowsCopied
End Sub
End Class
No comments have been posted about Use SQLBulkCopy Method To Transfer Data ...... This Is Use To Hundred Thousand Data In Several Seco. Why not be the first to post a comment about Use SQLBulkCopy Method To Transfer Data ...... This Is Use To Hundred Thousand Data In Several Seco.