-
Sep 27th, 2023, 02:22 PM
#1
Thread Starter
Frenzied Member
[VB6 RC6 SQLite] cConnection.OpenDB : Internally what happens if already open?
Example:
Code:
'In a Global module
Public Cnn As cConnection
Set Cnn = New cConnection
'In a form method
Cnn.OpenDB (App.Path & "\TLSDB\tools.db")
If the database has already been opened prior to coming to ...
Code:
Cnn.OpenDB (App.Path & "\TLSDB\tools.db")
... in another form method, no error occurs.
The code just sails through as if nothing is wrong.
So my question is (drumroll!): Is there a sort of "Open DB if not open, otherwise ignore the error" going on inside .OpenDB?
And if so, would it be good practice (or insurance) to simply add the .OpenDB() in methods that will be accessing the DB to insure no error of a closed DB occurs? No cost insurance?
TIA
-
Sep 28th, 2023, 12:41 AM
#2
Re: [VB6 RC6 SQLite] cConnection.OpenDB : Internally what happens if already open?
 Originally Posted by webbiz
If the database has already been opened prior to coming to ...
Code:
Cnn.OpenDB (App.Path & "\TLSDB\tools.db")
... in another form method, no error occurs.
Why would you expect an error?
The Cnn.OpenDB-call allows to Open (or Re-Open) "another DB-File" on an existing Cnn-instance.
(involving a proper cleanup of a potentially already pre-existing SQLite-DBFile-Handle beforehand).
You apparently decided, to do a "re-open" on the Cnn with the same DB-Filename for some reason...
 Originally Posted by webbiz
... would it be good practice (or insurance) to simply add the .OpenDB() in methods that will be accessing the DB to insure no error of a closed DB occurs?
No, good practice would be, to learn how to utilize Sub Main() as the "single entry-point into your App" -
wherein you can initialize and open all your "global Object-Variables" exactly once.
Olaf
Last edited by Schmidt; Sep 28th, 2023 at 01:08 AM.
-
Sep 28th, 2023, 04:55 AM
#3
Thread Starter
Frenzied Member
Re: [VB6 RC6 SQLite] cConnection.OpenDB : Internally what happens if already open?
 Originally Posted by Schmidt
Why would you expect an error?
The Cnn.OpenDB-call allows to Open (or Re-Open) "another DB-File" on an existing Cnn-instance.
(involving a proper cleanup of a potentially already pre-existing SQLite-DBFile-Handle beforehand).
You apparently decided, to do a "re-open" on the Cnn with the same DB-Filename for some reason...
No, good practice would be, to learn how to utilize Sub Main() as the "single entry-point into your App" -
wherein you can initialize and open all your "global Object-Variables" exactly once.
Olaf
Why expect an error? Not sure other than I had thought trying to open an already opened DB would produce one, much like trying to open a file that is already open (or in use).
Okay, back to Main() it is. I'll keep that in mind. Thanks.
-
Sep 28th, 2023, 08:14 AM
#4
Re: [VB6 RC6 SQLite] cConnection.OpenDB : Internally what happens if already open?
 Originally Posted by webbiz
Why expect an error? Not sure other than I had thought trying to open an already opened DB would produce one, much like trying to open a file that is already open (or in use).
That would sort of defeat the purpose of database files, no?
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
|