473,379 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Check if Database is Open

3
Hi!
I have been writing a VB desktop user program and website that are using an Access XP database. I recently ran in to problems with the database not being written to as it was already opened by someone else. My problem is the following; I need to be able to check to see if the database is opened by a different portion of the program before it attempts to write any changes. There are many functions/subroutines that use the database in both the website and desktop portions. Does anyone have any suggestions for how to check this status before the connection is opened? Thanks!

This is what I have so far, the problem is, I cannot access the function that called this code. (If this makes any sense, if not please let me know.)

Expand|Select|Wrap|Line Numbers
  1.     Private Sub TestIfOpen()
  2.         If Len(Trim(Dir("Z:\prntaudit\tcsss\tcsss.ldb"))) > 0 Then
  3.             ' Yup file is there
  4.             MessageBox.Show("Database is locked")
  5.             dbChkTmr.Enabled = True
  6.             intTmrChk = 0
  7.         Else
  8.             ' No file
  9.             MessageBox.Show("Database is open")
  10.             If dbChkTmr.Enabled = True Then
  11.                 dbChkTmr.Enabled = False
  12.             End If
  13.         End If
  14.     End Sub
  15.  
Thanks!
Thomas
Dec 18 '07 #1
4 11893
Dököll
2,364 Expert 2GB
This is what I have so far, the problem is, I cannot access the function that called this code. (If this makes any sense, if not please let me know.)

Expand|Select|Wrap|Line Numbers
  1.     Private Sub TestIfOpen()
  2.         If Len(Trim(Dir("Z:\prntaudit\tcsss\tcsss.ldb"))) > 0 Then
  3.             ' Yup file is there
  4.             MessageBox.Show("Database is locked")
  5.             dbChkTmr.Enabled = True
  6.             intTmrChk = 0
  7.         Else
  8.             ' No file
  9.             MessageBox.Show("Database is open")
  10.             If dbChkTmr.Enabled = True Then
  11.                 dbChkTmr.Enabled = False
  12.             End If
  13.         End If
  14.     End Sub
  15.  
Thanks!
Thomas
Hello, motpid!

I am not sure how this can be handled, just letting you know to stay tuned for added support:-)

In a bit!

Dököll
Dec 19 '07 #2
NeoPa
32,556 Expert Mod 16PB
Thomas,
Your code checks the LDB file. The presence of an LDB file simply shows that the database is open. It doesn't imply it's locked. That info may be held inside the LDB file but I don't know the layout so can't help much there I'm afraid.
I'm also sorry that I didn't really understand what your question meant. I can see the sort of thing you're trying to do (from your code) but the reference to a calling function and your inability to access it made no sense to me. Sorry.
Dec 19 '07 #3
motpid
3
Let me see if I can explain my problem a little more clearly. I have created a staff management system. The manager portion allows the manager to add/delete/update student information, create schedules, print reports, etc. There is a staff website and a program to report issues as well. The website allows the staff member to view a variety of schedules and submit hours they are available to work.
The problem that I am running into is that all 3 of these separate components use a single database and all write and read from this database as well. I need to find a way to check and see if the database is locked by another program/person before it attempts to write the new changes to the database. I have had issues with 2 staff members attempting to submit times they are available at the same from the website and only one persons records are saved.
I am using VB 2005 code in all 3 programs with db connections and commands to write/read to the database. Is there a simple way to embed an IF...ELSE statement before attempting to write to the database? Or maybe there is a better, easier way?
Thanks!
Thomas
Dec 20 '07 #4
NeoPa
32,556 Expert Mod 16PB
Some issues to consider then :
  1. This is the Access / VBA forum. I suspect most of what you're dealing with is VB related. I would suggest that forum may be of more help. I will throw in what I can though (On your request, I can move the thread to the VBA forum for you).
  2. Your code needs to ensure that the open type is always correct. Opening the database exclusively, for instance, when simply updating some data would be inappropriate. It may be that the return-code from one of the opens (database or recordset) may indicate the current state of the database or recordset. It should at least fail if it is locked and your open is correctly formatted.
  3. In VBA I would do a check of the status (if the previous item doesn't help) by using On Error ... before you try to access the table. If the command fails at least then you know that it has and you can report it to the user - or maybe even prompt to try again.
I suggest that the current code you're using (including the open commands) would be helpful before continuing. I suspect this would have to be passed over to VB in that case of course.
Let's hope you can make some progress with what I've already said though.
Let us know how you get on :)
Dec 20 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Wolfgang Kaml | last post by:
Hello All, I have been working on this for almost a week now and I haven't anything up my sleeves anymore that I could test in addition or change.... Since I am not sure, if this is a Windows...
6
by: mark4asp | last post by:
Hello, Is there a simple way to check whether a database driver is available on a remote server? I only have ftp access so I can only run ASP scripts. An ASP application on a host has...
3
by: RAD | last post by:
I am working with an evaluation copy of SQL Server 2000 for the first time; my DB experience lies with MS Access. I have a simple table in SQL Server (tblCompany) that has a field called...
6
by: joethis | last post by:
Is there a way to make sure that a file is already in use using asp? For instance, if one person has opened a file and is about to write to it; then is there a way to keep another user from...
7
by: Jared Evans | last post by:
I developed a console application that will continually check a message queue to watch for any incoming data that needs to be inserted into MS SQL database. What would be a low-cost method I...
1
by: scprosportsman | last post by:
Please help guys, i am trying to set up a database here at work and im fairly new to access in terms of writing functions and queries and stuff. I have 2 different places on my design that will...
2
by: V_S_H_Satish | last post by:
Dear Friends I am working as oracle and ms sql dba from last 4 years. My company recently migrated to DB2 databases. So i am very much new to db2 database Can any one pls provide script to...
14
by: martin1 | last post by:
All, I want to check wether db connection/open or not, if not it will post db connection error to user in message box The code is like: Dim objConnection As New SqlConnection _...
2
by: kevcar40 | last post by:
Hi is it posible to check if another database is open? i have several datasbase the first is a dbase where the local data is maintained on closing the database the table is exported to a holding...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.