首页 > Web开发 > 详细

vb.net BulkCopy的使用方法

时间:2020-04-21 16:22:12      阅读:123      评论:0      收藏:0      [点我收藏+]

‘Create a new StopWatch to measure the
‘ amount of time it takes to perform the
‘ insert
Dim swatch As New Stopwatch()
swatch.Start()
‘Configure the connection string
Dim cnString As String = "Data Source=;Initial Catalog=;Integrated Security=False;User ID=;Password=;"
‘Create a new SqlBulkCopy class
Dim bcp As New SqlClient.SqlBulkCopy(cnString, SqlClient.SqlBulkCopyOptions.KeepNulls)
‘You MUST specifiy the table you are going to fill
bcp.DestinationTableName = "Table Name"
‘Increase the timeout to a more appropriate time
‘ for the amount of data your are inserting.
‘ The default is 30 seconds
bcp.BulkCopyTimeout = 6000
‘Write the data to the SQL Server Database table
bcp.WriteToServer(Data Table)
‘Close the instance
bcp.Close()
‘Stop the Stopwatch!
swatch.Stop()
MsgBox("Done! Elapsed Milliseconds: " & swatch.ElapsedMilliseconds)

vb.net BulkCopy的使用方法

原文:https://www.cnblogs.com/revgin/p/12745140.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!