As you know, @@TRANCOUNT is used to inform you about the number of live transactions active at point. If you want to retrieve it's value using an application, you should be careful about the behaviour of the returned value. Let us consider the procedurecreate procedure get_count
as
select @@TRANCOUNT as trancountConsider the VB code that calls the procedurePrivate Sub Form_Load()
as
begin transaction
select @@TRANCOUNT
rollback transaction Read more: Beyond Relational
as
select @@TRANCOUNT as trancountConsider the VB code that calls the procedurePrivate Sub Form_Load()
Dim con As New ADODB.ConnectionEnd SubThe result is 0 eventhough there is transaction activated by application Alter the procedure like belowalter procedure get_count
Dim rs As New ADODB.Recordset
con.Open "connection string"
con.BeginTrans
Set rs = con.Execute("exec get_count")
MsgBox rs("trancount")
con.CommitTrans
as
begin transaction
select @@TRANCOUNT
rollback transaction Read more: Beyond Relational
0 comments:
Post a Comment