事务提交

'添加事务提交 

Dim con As SqlConnection = New SqlConnection(frmSetting._DatabaseProvider.GetConnectionString) 

Dim cmd As SqlCommand = New SqlCommand() 

Dim tran As SqlTransaction

 con.Open()

 tran = con.BeginTransaction() 

cmd.Connection = con 

cmd.Transaction = tran 

Try 

cmd.CommandText = tmpSQL 

cmd.ExecuteNonQuery() 

tran.Commit() 

con.Close() 

Catch ex As Exception

 tran.Rollback() 

con.Close() 

End Try 

 

你可能感兴趣的:(事务)