darkmastergyz
08-08-2007, 08:46 AM
I heard for good database practices, whenever you're done with opening and using a database, you should close the connection. So if I have an example connection like this, are the statements at the end enough?
dim db as database
dim rs as recordset
set db = current db
dim strSQL as string
strSQL = "SELECT * FROM db"
set rs = db.openrecordset(strSQL, openDynaSet)
(END):
set rs = nothing
rs.close
set db = nothing
db.close
DJkarl
08-08-2007, 08:50 AM
I heard for good database practices, whenever you're done with opening and using a database, you should close the connection. So if I have an example connection like this, are the statements at the end enough?
dim db as database
dim rs as recordset
set db = current db
dim strSQL as string
strSQL = "SELECT * FROM db"
set rs = db.openrecordset(strSQL, openDynaSet)
(END):
set rs = nothing
rs.close
set db = nothing
db.close
The "end" statements are backwards, the close needs to come before you set the object to nothing otherwise you will get an error.
Should be:
(END):
rs.close
set rs = nothing
db.close
set db = nothing
pbaldy
08-08-2007, 09:49 AM
Yes, in fact I've read that you really only need one or the other, so I usually just set to nothing.
Rabbie
08-08-2007, 11:29 AM
I have heard that the .close makessure that any changes are written back to the file. Setting the rs to nothing frees up any dynamic resources used in Access.
pbaldy
08-08-2007, 12:03 PM
I have heard that the .close makessure that any changes are written back to the file.
That is not correct. According to Help, changes will be lost if the recordset is closed before .Update is executed.