Try
Connections("salaryMS").BeginTransaction() '开始事务
For Each r As Row In t.Rows
GH=r("工号")
XM=r("姓名")
Dim cmd As New SQLCommand
Dim dt As DataTable
cmd.ConnectionName = "123456"
cmd.CommandText = "Insert Into {报盘记录} ([工号],[姓名]) Values ('" & GH & "','" & XM & "')"
cmd.ExecuteNonQuery
Next
Connections("salaryMS").Commit '提交事务,所有操作生效
Catch ex As Exception '如果出错
Connections("salaryMS").Rollback() '回滚事务,撤销所有操作
End Try
[此贴子已经被作者于2015/8/31 9:37:31编辑过]