復制代碼 代碼如下:
'數據更新
Public Sub updateTable(ByVal StrSql As String)
objCommand.CommandText = StrSql
Try
conSql.Open()
Trans = conSql.BeginTransaction
objCommand.Transaction = Trans
objCommand.ExecuteNonQuery()
Trans.Commit()
Catch ese As Exception
MsgBox(ese.Message)
Trans.Rollback() '如果更新異常則取消所有更新
Finally
conSql.Close() '關閉連接
End Try
End Sub