Try Connections("salaryMS").BeginTransaction() '开始事务 Dim dt As DataTable Dim cmd As New SQLCommand cmd.C For Each r As Row In t.Rows GH=r("工号") XM=r("姓名") cmd.CommandText = "Insert Into {报盘记录} ([工号],[姓名]) Values ('" & GH & "','" & XM & "')" cmd.ExecuteNonQuery Next Connections("salaryMS").Commit '提交事务,所有操作生效 Catch ex As Exception '如果出错 Connections("salaryMS").Rollback() '回滚事务,撤销所有操作 End Try