Set Adotemp1_Cal = New ADODB.Recordset
Set Conntemp1_Cal = New ADODB.Connection
Set Cmdtemp1 = New ADODB.Command
Conntemp1_Cal.Open cntstrtemp
Cmdtemp1.ActiveConnection = Conntemp1_Cal
Adotemp1_Cal.CursorLocation = adUseClient
Adotemp1_Cal.CursorType = adOpenkeyset
Adotemp1_Cal.LockType = adLockOptimistic
Cmdtemp1.CommandText = "delete from 营业明细"
Set Adotemp1_Cal = Cmdtemp1.Execute
.........(又往表中写入10条数据)
Cmdtemp1.commandtext="select * from 营业明细"
此时Adotemp1_cal.Recordcount竟然是-1
请问怎么回事???
Set Conntemp1_Cal = New ADODB.Connection
Set Cmdtemp1 = New ADODB.Command
Conntemp1_Cal.Open cntstrtemp
Cmdtemp1.ActiveConnection = Conntemp1_Cal
Adotemp1_Cal.CursorLocation = adUseClient
Adotemp1_Cal.CursorType = adOpenkeyset
Adotemp1_Cal.LockType = adLockOptimistic
Cmdtemp1.CommandText = "delete from 营业明细"
Set Adotemp1_Cal = Cmdtemp1.Execute
.........(又往表中写入10条数据)
Cmdtemp1.commandtext="select * from 营业明细"
此时Adotemp1_cal.Recordcount竟然是-1
请问怎么回事???
Conntemp1_Cal.CursorLocation = adUserClient
就OK了
之后再看看Conntemp1_Cal.CursorLocation的值试试
msgbox "没有记录"
else
Adotemp1_cal.movenext
msgbox "记录数量=" & Adotemp1_cal.recordcount
endif
Adotemp1_Cal.LockType = adlockreadonly
我是用insert into来添加的记录。
Set Conntemp1_Cal = New ADODB.Connection
Conntemp1_Cal.Open cntstrtemp Conntemp1_Cal.BeginTrans Conntemp1_Cal.Execute "delete from 营业明细" .........(又往表中写入10条数据) Conntemp1_Cal.CommitTrans Adotemp1_Cal.CursorLocation = adUseClient
Adotemp1_Cal.CursorType = adOpenKeyset
Adotemp1_Cal.LockType = adLockOptimistic
Adotemp1_Cal.Open "select * from 营业明细", Conntemp1_Cal
Conntemp1_Cal.CursorLocation = adUserClient