LDB question

  • Thread starter Vladimír Cvajniga
  • Start date
V

Vladimír Cvajniga

A while ago we had a discussion about persistent connection (which I tried
once and never since). I plan to check "BE-MDB-open-status" on it's LDB, ie.
LDB exists = MDB is open
LDB doesn't exists = MDB is closed
(I suppose that in such case persistent connection cannot be used.)

But after an accident it may result incorrect MDB status since LDB may not
be deleted. Is there a safer way to check if MDB is open?

TIA

Vlado
 
A

Allen Browne

How about OpenDatabase with the Exclusive option.
If the file is already in use, that should fail.

Testing the LDB is not ideal: it applies only when the database is open
shared.
 
V

Vladimír Cvajniga

Thanks very much, Allen. That's exactly what I needed. It works perfectly!

Vlado
 
V

Vladimír Cvajniga

Public Function fncIsOpenMDB(ByVal strPath As String) As Boolean
Dim db As DAO.Database

On Error Resume Next
fncIsOpenMDB = False
Set db = DBEngine.OpenDatabase(strPath, True)
fncIsOpenMDB = (Err <> 0)
db.Close
Set db = Nothing

End Function
 
T

Tony Toews [MVP]

Vladimír Cvajniga said:
A while ago we had a discussion about persistent connection (which I tried
once and never since).

Why? That is why did you try once and never again? I vaguely recall
the discussion but forget the details.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
 
T

Todos Menos [MSFT]

Tony

I never claimed to be an employee of Microsoft
SERIOUSLY DUDE GIVE UP


I just choose to list my 'favorite stock to short' in my caption


You _PLEASE_ tell me where I'm claiming to work for Microsoft.
I never agreed to those terms and conditions.


AND I HAVE NO PROOF THAT YOU ARE AN MVP!


a) I am right
b) you have credibility because you're an MVP
c) you should be using your MVP in order to get MIcrosoft to STFU and
fix bugs
d) you are a waste of space because you haven't grown past DAO and
MDB


until you lose the training wheels; stick a fork in it, kid


MS SELLS BUGGY SOFTWARE AND I AM DONE ACCEPTING MEDIOCRITY


they need to start testing this shit; before they sell it-- instead
of
focusing on IPTV and Xbox and Zune and inventing new .NET _CRAP_
 
V

Vladimír Cvajniga

It didn't seem to have an effect. Instead, it took very long to run the
program from another machine if different station has run it as well.
I had a persistent connection based on an empty recordset. Some programmers
say I might have create a persistent connection just by initializing db
variable pointing to the back end. I tried persistent connection according
to http://www.granite.ab.ca/access/performanceldblocking.htm:
Public rsAlwaysOpen As Recordset

Private Sub Form_Close()
rsAlwaysOpen.Close
Set rsAlwaysOpen = Nothing
End Sub

Private Sub Form_Open(Cancel As Integer)
Set rsAlwaysOpen = CurrentDb.OpenRecordset("DummyTable")
End Sub

I didn't try David Fenton's Global database connection as described on the
web page. Here are the steps how I did it:

StartUp Form = frm_Main
On Form_Open
1) First action: check connections to shared BE database within a "For Each
tbl In CurrentDb.TableDefs" cycle:
If any connection failed (ie. BE MDB couldn't be found, eg. after a FE
upgrade) there was "Exit For", and a procedure to re-create connections was
run.
2) Set rsVzdy = CurrentDb.OpenRecordset("VZDY") 'open persistent connection
Table VZDY was a table in main shared BE MDB.
3) Initiate main MDB's parameter tables (if run for the first time).
4) Initiate local BE MDBs.
5) Initiate frm_Main (dashboard). There are many actions on shared BE MDB,
eg. reading from parameter tables, etc.


On Form_Close
1) Write some settings to Win registry and to INI-file.
2) Set rsVzdy = Nothing 'close persistent connection
3) Write to a log file (pure TXT file).
4) Compress local BD MDBs.
5) Last user of main BE MDB: backup main MDB.

It's all A97, Czech version. I believe there are no (Jet) DB issues
associated with A97 language versions.
According to some comments (Albert Kallal, David Fenton, ...) I did
something wrong, but I don't know what. :-/

Pls, respond if you have any idea. At the moment we don't use persistent
connection at all. Instead we do some registry tricks, see
http://support.microsoft.com/kb/150384/ and the program performance is
superb! What do you think: should I go back and try persistent connection
once again? ;-)

TIA

Vlado
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top