PeregrinTook
Registered User.
- Local time
- Today, 07:27
- Joined
- Aug 1, 2006
- Messages
- 15
Hey all,
Recently my access 2k3 db started giving me an error when using the compact & repair option, telling me it may be corrupt.
I've done a bit of research and found that part of the problem at least stemmed from saving & exiting the app without closing off all opened connections.
I think I've remedied that now, but wonder if part of what I'm doing is not quite right, or not good practice at least? I'd like to hear your opinions please...
Ok so for any routines where I'm looking to build & work with a recordset, I do something like the following:
Then I make sure I close off the connection when done to avoid any problems:
But sometimes I only want a count or a single value back from a table/query, so currently just do something like this:
My question is this though. In the second example, is this bad practice because I'm not closing off the OpenRecordset connection? Should I always set the connection explicitly like in the first example so I ensure it gets closed off, or is there another 'acceptable' method of achieving the second scenario?
I'd like to hear your thoughts please, as I can't quite seem to clarify this through searching the net...
Thanks in advance
J
Recently my access 2k3 db started giving me an error when using the compact & repair option, telling me it may be corrupt.
I've done a bit of research and found that part of the problem at least stemmed from saving & exiting the app without closing off all opened connections.
I think I've remedied that now, but wonder if part of what I'm doing is not quite right, or not good practice at least? I'd like to hear your opinions please...
Ok so for any routines where I'm looking to build & work with a recordset, I do something like the following:
Code:
Set rstSource = gdbsCurr.OpenRecordset(pstrSQL)
Then I make sure I close off the connection when done to avoid any problems:
Code:
rstSource.Close
Set rstSource = Nothing
But sometimes I only want a count or a single value back from a table/query, so currently just do something like this:
Code:
If gdbsCurr.OpenRecordset(pstrSQL)!Count = 0 Then GoTo PROC_EXIT
My question is this though. In the second example, is this bad practice because I'm not closing off the OpenRecordset connection? Should I always set the connection explicitly like in the first example so I ensure it gets closed off, or is there another 'acceptable' method of achieving the second scenario?
I'd like to hear your thoughts please, as I can't quite seem to clarify this through searching the net...
Thanks in advance
J