日期:2014-05-18  浏览次数:20433 次

VB6+ACCESS 在事务控制中为什么两条语句不可同时执行
开发环境 VB6+ACCESS2003

具体语句如下(YHXX的字段有:用户编号,用户卡号,状态,关系,标识) :

  sql1 = " update yhxx set 标识='',关系='无效' where 用户编号=1 and 状态='正常' and 关系='有效' and 标识='有效' "
   
  sql2 = " update yhxx set 关系='无效' where 用户卡号=2 and 状态='正常' and 关系='有效' and 标识='有效' "
   
  On Error GoTo Errb
  Dim cc As Boolean
  Conn.BeginTrans
   
  If Check1.value = 1 Then '开户错
  Conn.Execute sql1, n1
  Conn.Execute sql2, n2
  conn.committrans
   
  sql1和sql2应该是各作用一条记录,两条记录互不相干,但是执行后却

  发现
  Conn.Execute sql1, n1
  Conn.Execute sql2, n2

  执行完后n1=1 ,n2=0

  改变一下顺序
  Conn.Execute sql2, n2
  Conn.Execute sql1, n1

  执行完后n2=1 ,n1=0

  导致 此事务不能完成
   
  请问是何原因。  




------解决方案--------------------
ACCESS ??建议你去相应版块
------解决方案--------------------
探讨
开发环境 VB6+ACCESS2003

具体语句如下(YHXX的字段有:用户编号,用户卡号,状态,关系,标识) :

sql1 = " update yhxx set 标识='',关系='无效' where 用户编号=1 and 状态='正常' and 关系='有效' and 标识='有效' "

sql2 = " update yhxx set 关系='无效' whe……