事务滚回的问题
我有一个保存事件
Private Sub cmdsave_Click()
On Error GoTo ERR:
c_CON.db.BeginTrans'开始事务
for i=1 to 10
'插入入库记录的代码
( 略)
'在这里我有一个全局过程
Call UpdateYmjy(100,150)
next
c_CON.db.CommitTrans '提交事务
ERR:
c_CON.db.RollbackTrans
MsgBox "发生错误,调价不成功 " & Ssql & "", vbCritical
end sub
Public Sub UpdateYmjy(sl As Double, je As Double)
Dim Wsl As ADODB.Parameter
Dim Wje As ADODB.Parameter
Dim Mycommand As New ADODB.Command
Mycommand.ActiveConnection = c_CON.db.Connect '对象的连接字符串和上面是一样的即也是 c_con的连接字符串
Set Wsl = New ADODB.Parameter
Wsl.Type = adDouble
Wsl.Value = sl
Mycommand.Parameters.Append Wsl
Set Wje = New ADODB.Parameter
Wje.Type = adDouble
Wje.Value = je
Mycommand.Parameters.Append Wje
Mycommand.CommandText = "gxymjyb"‘存储过程
Mycommand.CommandType = adCmdStoredProc
Dim ree As New ADODB.Recordset
Set ree = Mycommand.Execute()
end sub
我想请教的问题是:如果错误发生的滚回c_con对象倒是容易,但Mycommand
怎么滚回呢!(mycommand 是在过程内 是不是也可以定义成一个全局的对象叱!)