# Re: 更正: RDC的指标不会被关闭, 只有RdoResultset关闭

Posted by Lisa Chang on August 14, 1997 at 02:51:37:

In Reply to: 更正: RDC的指标不会被关闭, 只有RdoResultset关闭 posted by Lisa Chang on August 14, 1997 at 02:22:23:

exmple:
Dim cn As rdoConnection
Dim en As rdoEnvironment, conn As String
Dim rs1 As rdoResultset

Private Sub Form_Load()
Set en = rdoEnvironments(0)
en.CursorDriver = rdUseServer
conn = "UID=D112;PWD=2321;DATABASE=DFD1;SERVER=DDFDHEM;DRIVER={SQL SERVER};DSN='';"
Set cn = en.OpenConnection(dsname:="", Prompt:=rdDriverNoPrompt, Connect:=conn)
Set rs1 = cn.OpenResultset("select * from test3", rdOpenKeyset, rdConcurLock)
Set MSRDC1.Resultset = rs1 'RDC
Text1.DataField = "t2" 'DATA FIELD
cn.Execute "begin transaction", rdExecDirect
'cn.BeginTrans
rs1.Edit
rs1("t2") = 44
rs1.Update
cn.Execute "rollback transaction", rdExecDirect '会做rollback
'cn.RollbackTrans RDO2.0 BUG: 不会做异动回复的动作
rs1.MoveNext 'RDO2.0 BUG: transaction结束后,cursor会关闭, 只好用move来解
rs1.MoveFirst ' 决这个问题
MsgBox rs1("t2")
End Sub

Private Sub Form_Unload(Cancel As Integer)
Set rdotrans = Nothing
End Sub

Follow Ups: