pb transaction有关问题

pb transaction问题
我在用的oracle数据库,在一个commonbutton 打印控件中首先打印第一条记录,打印后该记录自动消失,如果还有第二条记录,将打印第二条记录。
在打印控件中
if ……then
tr1 =create transaction
tr1.DBMS = "MSS Microsoft SQL Server"
tr1.Database = ……
  tr1.LogPass = ……
  tr1.ServerName = ……
  tr1.LogId = ……
tr1.AutoCommit = False
tr1.DBParm = ""
connect using tr1;
if tr1.sqlcode = 0 then
int li_count
SELECT count(*)
INTO :li_count
FROM tbl_ck
  where SPHM =:ls_xtxh using tr1;
if li_count > 0 then
messagebox("","此票已经打印,不能重复打印")
return
end if
else
messagebox("","数据库连接失败!")
return
end if
end if


现在的问题是打印一次成功后第二次时tr1.sqlcode = -1,如果想打印则需要退出重新进入打印界面
第二次时让tr1.sqlcode 也为0!谢谢各位指点

------解决方案--------------------
使用完tr1后,加上
disconnect using tr1;
destroy tr1