Dim CNN As New ADODB.Connection
If CNN.State Then CNN.Close
With CNN
.ConnectionString = Conn_str 'Conn_str为链接字符串
.CursorLocation = adUseClient
.CommandTimeout = 10
.Open
End With
CNN.BeginTrans
'你的execute语句
If CNN.Errors.count <> 0 Then '出错
MsgBox "数据库操作错误", vbCritical + vbOKOnly
CNN.RollbackTrans
'放置失败指令
else '执行成功
CNN.CommitTrans '提交事务
'放置成功指令
end if