# Re: 请教这个程式错在那里?

Posted by kkcheung on September 13, 1999 at 16:17:18:

In Reply to: Re: 请教这个程式错在那里? posted by 阿拉 on September 11, 1999 at 13:28:58:

: : selstr = "select * from sale_rec where sale_date like '" + Trim(T_FROM.Text) + "%'"

: : Set tempset = FMSDB.OpenRecordset(selstr, dbOpenSnapshot, dbSQLPassThrough)
: : If tempset.EOF Then
: : MsgBox "在指定条件下无查询资料 !", , FRM_KHGH_Q_P.Caption
: : MSG_BAR.Caption = ""
: : Exit Sub
: : End If
: : Do While Not tempset.EOF
: : temp_inv = Trim(tempset.Fields!invo_code): temp_lot = Trim(tempset.Fields!stockno)

: : selstr2 = "select * from receive_rec where stock_no='" + temp_lot + "'"
: : Set tempset2 = FMSDB.OpenRecordset(selstr2, dbOpenSnapshot, dbSQLPassThrough)

: : If Not tempset2.EOF Then
: : temp_sendcode = Trim(tempset2.Fields!send_code)
: : sqlSTR = "UPDATE sale_rec SET send_code= '" + temp_sendcode + "' WHERE invo_code='" + temp_inv + "' and stockno='" + temp_lot + "'"
: : BeginTrans
: : FMSDB.Execute sqlSTR, dbSQLPassThrough
: : End If

: : tempset.MoveNext
: : tempset2.Close
: : Loop
: : 上面的程式可以顺利执行到第一次loop后,当第二次执行Set tempset2 = FMSDB.OpenRecordset(selstr2, dbOpenSnapshot, dbSQLPassThrough),就出现ODBC-call failed 3146.我作程式追踪,selstr2这句是完整的,抄到visdata亦可执行,但在这里却过了,请教问题出在那里.谢谢大家!

: 应该是有BeginTrans, 但没有CommitTrans

我将CommitTrans加到tempset2.Close4后,我尝试了好几个日子运行,但tempset.MoveNext每到第次便odbc call fialed-3146.为什么呢?

Follow Ups: