|
-
August 27th, 2001, 06:35 AM
#1
rs.open or not
Hi out there,
How can I check if a recordset is open or closed? If I unload a form usually a recordset is still open, but on one occation it's closed.
The recordset is not nothing then.
Anybody got an Idea?
have a nice day,
Patzer
have a nice day
Patzer
_____________________________
Philo will never be forgotten
-
August 27th, 2001, 06:39 AM
#2
Re: rs.open or not
For ADO, you can use the next code
If rst.state = adStateClosed then
Msgbox "Recordset is closed"
else
Msgbox "Recordset is open"
End If
Tom Cannaerts
[email protected]
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
-
August 27th, 2001, 07:41 AM
#3
Re: rs.open or not
thanx a lot!!!
simple when you know how (as always in VB).
have a nice day,
Patzer
have a nice day
Patzer
_____________________________
Philo will never be forgotten
-
August 29th, 2001, 03:37 AM
#4
Re: rs.open or not
you can use the state property of the recordset if the recordset is open the rs.state value will be 1 and if the recordset is closed the rs.state value will be 0.this will help you to determine whether the recordset is open or closed.
-
August 29th, 2001, 03:43 AM
#5
Re: rs.open or not
no.. it' not correct...
rs.state=0 then rs is closed...
bur rs.state=1 is not a correct test...
an rs can be in adStateOpen and adStateFetching ...so its state is 9...
the correct test is
'with reference
if rs.state and adstateopen then
'so i'm sure rs is open
end if
'without reference
if rs.state and 1 then
'so i'm sure rs is open
end if
hi,brt
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
-
August 29th, 2001, 04:46 AM
#6
Re: rs.open or not
Hi,
I have to admit that I do not really understand your idea so:
If a recordset.state returns true for adStateFetching at a time, does it also return true for adStateOpen at that time?
I mean there are also other states for the rs, as of adstateconnecting and adstateexecuting, so could you please give a little more Information on that?
thx´
have a nice day,
Patzer
have a nice day
Patzer
_____________________________
Philo will never be forgotten
-
August 29th, 2001, 04:54 AM
#7
Re: rs.open or not
the rs.state is a sum of state...
adStateClosed = 0 'bynary ->0000
adStateOpen = 1 'bynary ->0001
adStateConnecting = 2 'bynary ->0010
adStateExecuting = 4 '0100
adStateFetching = 8 '1000
if U want tio check state U must have a bynary check rs.state AND constant -> but it is a bad test when rs.state=adstateopen
so if (rs.state and adstateopen)=false then rs is closed...
exaple rs.state=adstateopen+adstateexecuting
so rs.state=5 -> 0101...
hi,btr
<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/im...ertaplanet.gif'>
</center>
-
August 30th, 2001, 06:57 AM
#8
Re: rs.open or not
Hi Berta,
thx, took some time but then I understood (I think I did :-))
have a nice day,
Patzer
have a nice day
Patzer
_____________________________
Philo will never be forgotten
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|