Click to See Complete Forum and Search --> : help... About Connection and Recordset
Wen Lie
Nov 15th, 1999, 10:18 AM
Dear All...
I need some help...
How should I do if I want to check whether a connection or recordset is open or closed ?
Thx a lot...
BRgds,
Wille
Junior VB Programmer
Manish
Nov 15th, 1999, 10:29 AM
which database object u r using???
if its ADO u can use state property of ADO connection object and recordset object
Thanx Manish
Wen Lie
Nov 15th, 1999, 10:35 AM
Dear Manish,
I used ADO Connection...
I mean everytime I want to use :
Myconn.close
or
MyRecord.close
I want to check it first whether it is open or closed...
And everytime I want to open a connection or recordset, I also want to check it first...
Thx a lot...
Help me plz...
Wille
Junior VB Programmer
Manish
Nov 15th, 1999, 11:39 AM
U can use the state property of the recordset and connection object
if dbConnection.state=adstateopen then
' place here the code to use existing connection
else
' place here the codes for opening a connection
endif
there are the possible values for State property
adStateOpen
adStateClose
adStateConnecting
adStateExecuting
adStateFetching
Brgds Manish
Wen Lie
Nov 15th, 1999, 12:08 PM
Dear Manish...
You said that the statement would be like below :
if dbConnection.state=adstateopen then
' place here the code to use existing connection
else
' place here the codes for opening a connection
endif
then... I'm still confuse about the code to use existing connection....
Could u explain more... how to use existing connection ???
Thx again.....
Wille
Junior VB Programmer
Manish
Nov 15th, 1999, 02:38 PM
HI
it is like this
let say u hv previously created a connection object and opened it for operations and now again u want to use that connection and u want to check if the connection is still open or not. Let say u want to open a recordset
now before setting the currentconnection property of then recordset place this code
if dbconnection.state=adStateClose then
' this part will be executed only when the the connection is close before setting the active conection property of the recordset object connection must be open...
so her place the code to open the connection then.
end if
now set the activeconnection property of the recordset.
and now open the recordset
Thanx Manish
Wen Lie
Nov 15th, 1999, 03:03 PM
Dear Manish...
Thx for your help...
it helps me a lot...
Wille
Junior VB Programmer
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.