I don't know if this should be here or in an Access forum but here goes
I have a VB6 program that uses an access database to record competitors and scores from a competion this works fine and i will call this database (A)
after each update is made database (A) copies itself to a preset location which I will call database (B)
so far everything is fine
at a remote location there is another computer with a cut down version of the main program which only allows competitors to view the results this uses a database I will call (C)
database (C) is a copy of database (B) and it also updates every time you return to the main selection screen
everything works fine for 99% of the time until database (C) attempts to copy (B) just at the point (A) is copying to (B) and the program on the remote computer crashes
and now to the question
does anyone know of a way of trapping the error caused by (C) trying to copy the database (B) when it is locked by (A) updating (B)
All I would require is for the remote computer to skip the update and just try again next time
I hope this makes sense and someone may be able to help me get past this annoyance as simply as possible
Many thank in advance
Regards Rob
20 1638
On a slight tangent, you might be able to reduce the chances of it happening by doing the A->B copy in two stages. - Copy A to B's location with a different name
- Delete B and rename the copy.
End result is the same, but you spend much less time with B unavailable.
Um...
I think I may have missed the point of the question. I was assuming you were talking about copying the database files to another location. Were you actually referring to copying records from one database to another?
... after each update is made database (A) copies itself to a preset location which I will call database (B) ...
This is simple; create a lock file called (something.lock). No magic about the lock file. It's simply an empty file.
Before (A) updating (B), it creates a lock file. (C) will skip update from (B) till lock file is deleted.
When (A) completes updating (B), it delete lock file. So (C) can continue update data from (B).
This is simply create a lock file called (something.lock). No magic about the lock file. It simply an empty file.
Before (A) updating (B), it create an lock file. (C) will skip update from (B) till lock file is deleted.
When (A) completelly update (B), it delete lock file. So (C) can continue update data from (B).
Thats exactly the problem when it finds the lock file it crashes the program.
I need to find a way for it to skip the update when it finds the lockfile
Many thanks for the replies so far, keep them coming
On a slight tangent, you might be able to reduce the chances of it happening by doing the A->B copy in two stages.- Copy A to B's location with a different name
- Delete B and rename the copy.
End result is the same, but you spend much less time with B unavailable.
Um...
I think I may have missed the point of the question. I was assuming you were talking about copying the database files to another location. Were you actually referring to copying records from one database to another?
No you were right the first time it is copying one database file but it doesn't matter which way i do it if it finds a lock file then it 'bombs' (and I must admit its only now and again) but I cant even make it restart automatically as it asks for a password to close it down so that the competitors cannot shut it down
No you were right the first time it is copying one database file but it doesn't matter which way i do it if it finds a lock file then it 'bombs' (and I must admit its only now and again) but I cant even make it restart automatically as it asks for a password to close it down so that the competitors cannot shut it down
So, do you have any control over the program which is bombing? Can you rewrite it?
In any case, my suggestion should at least reduce the scale of the problem, since the file would be unavailable for a very brief period.
So, do you have any control over the program which is bombing? Can you rewrite it?
In any case, my suggestion should at least reduce the scale of the problem, since the file would be unavailable for a very brief period.
I wouldn't like to have to rewrite it but could certainly modify part of it, as i said at the start 99% of the time its fine but just occasionally it bombs.
The copy only takes a couple of seconds anyway (it is a finite database as it is only used once a year for one 4 day competition and is cleared back to zero at the end ready for next year)
I wouldn't like to have to rewrite it but could certainly modify part of it, as i said at the start 99% of the time its fine but just occasionally it bombs. ...
Sounds, then, as though it should be relatively simple to have it retry if the copy fails. But I don't think we have anything like enough information about that program to advise.
I wouldn't like to have to rewrite it but could certainly modify part of it, as i said at the start 99% of the time its fine but just occasionally it bombs.
The copy only takes a couple of seconds anyway (it is a finite database as it is only used once a year for one 4 day competition and is cleared back to zero at the end ready for next year)
The copy takes only a couple of seconds. The comptition apprear once a year. havent you got enought time to make the copy?
The copy takes only a couple of seconds. The comptition apprear once a year. havent you got enought time to make the copy?
Must be a biiig file, huh. :)
Of course, I did once have a Windows file-copy dialogue tell me there were about 17 million seconds remaining...
Seriously, the file is only copied when updates are happening, so that would be during the competition.
Must be a biiig file, huh. :)
Seriously, the file is only copied when updates are happening, so that would be during the competition.
Awh, thats bad. I havent understand his mind yet.
No problem. Thats technique is as the same as the lock file. (now, we're using another file - instead of lock-file- it can be called: mark-file)
+ (A) will send data to (B) every time it has new data. When sending complete, it create a mark-file (called: anything.mrk) to tell (C) that: it's time to update.
+ (C) will skip update data from (B) till it see the mark-file. When updating is completed, (C) removes mark-file (thats tell to (A) that: ready to receive newer data, and tell to it-selft that: the data from(B) is now old, no need to update)
+ (A) has new data, it must take a look that: havent (C) completed updating data yet?(by looks into mark-file). If mark-file still existing, (A) will skip sending data to (B) till mark-file is removed.
Awh, thats bad. I havent understand his mind yet.
No problem. Thats technique is as the same as the lock file. (now, we're using another file - instead of lock-file- it can be called: mark-file)
+ (A) will send data to (B) every time it has new data. When sending complete, it create a mark-file (called: anything.mrk) to tell (C) that: it's time to update.
+ (C) will skip update data from (B) till it see the mark-file. When updating is completed, (C) removes mark-file (thats tell to (A) that: ready to receive newer data, and tell to it-selft that: the data from(B) is now old, no need to update)
+ (A) has new data, it must take a look that: havent (C) completed updating data yet?(by looks into mark-file). If mark-file still existing, (A) will skip sending data to (B) till mark-file is removed.
I am now totally confused!!!
Surely if (C) can check for a 'mark-file' it could check for the presence of the 'lock-file' and just skip the copy if its there?
I am now totally confused!!!
Surely if (C) can check for a 'mark-file' it could check for the presence of the 'lock-file' and just skip the copy if its there?
Yes, I'm inclined to agree.
Is it possible you could create a program which would simply copy the updated data from one database to the other, without having to copy the entire file? Or perhaps have A/B use the file in a shared mode, so C doesn't bomb when it tries to copy? (This last would have to be very thoroughly tested in case it allowed corruption of the data at C.)
I am now totally confused!!!
Surely if (C) can check for a 'mark-file' it could check for the presence of the 'lock-file' and just skip the copy if its there?
Mark-file is abit diffrent from lock-file. If lock-file exist, (C) will skip update (because (A) havent finished sending data yet). If mark-file exist, (C) will update data from (B) because the mark-file used to caution: have new data.
If you use mark-file, forgot all about the lock-file.
The client machine (C) will check the mark-file each time it need infomation from database. If mark-file exist, call updating process before reading database infomation.
Say something about updating process:
+ First: Copy data file from (B) to (C) with different name.
+ Close current connection.
+ Re-Open connection with new Data Source (can change datasource by Connection String), that refers to new database.
+ Remove mark-file
+ No need restarting program.
+ You should store atleast 2 filenames. On client app start, use the first file name. On updating database, use the second. On updating again, use the first...and so on.
Ah! So the "mark file" is basically a sign saying "fresh data here, get it while it's hot".
Mark-file is abit diffrent from lock-file. If lock-file exist, (C) will skip update (because (A) havent finished sending data yet)..
That would be fine if it would just skip the update cos it will try and update as soon as someone looks at another score which is very frequently
The problem is it won't skip if it can't update it just 'bombs'
all I need to know is how to make it skip on finding the lock file
That would be fine if it would just skip the update cos it will try and update as soon as someone looks at another score which is very frequently
The problem is it won't skip if it can't update it just 'bombs'
all I need to know is how to make it skip on finding the lock file
For that, I think we will need more detail on what it is doing, and how, and what version of VB it is written in.
Can we see the code which is bombing? It might be as simple as doing something like On Error Resume Next and checking Err.Number to see whether the copy worked.
That would be fine if it would just skip the update cos it will try and update as soon as someone looks at another score which is very frequently
The problem is it won't skip if it can't update it just 'bombs'
all I need to know is how to make it skip on finding the lock file
Now, say something about skip updating:
the old process maybe like: -
Private Sub cmdShowScore_Click()
-
score = getScoreFromDataBase()
-
Display score
-
End Sub
-
the new process must be: -
Private Sub cmdShowScore_Click()
-
If isExistingMarkFile Then
-
call updatingDataBase()
-
End If
-
score = getScoreFromDataBase()
-
Display score
-
Ens Sub
-
Private Function isExistingMarkFile() As Boolean
-
Dim fileName As String
-
fileName = "path to markfile"
-
If Dir(fileName)<>"" Then
-
isExistingMarkFile = True
-
Else
-
isExistingMarkFile = False
-
End If
-
End Function
-
Private Sub updatingDataBase()
-
'use each diffent file name for each time need updating
-
If currDbname = "(C)\db2.mdb" Then
-
currDbName = "(C)\db1.mdb" 'here is global varriable, use to store current database file name
-
Else
-
currDbName = "(C)\db2.mdb"
-
End If
-
FileCopy "(B)\db1.mdb" currDbName 'overwrite old file if you need
-
'close current connection
-
con1.Close
-
'refer connection to new database
-
con1.ConnectionString ="Provider=Microsoft.Jet.OLEDB.4.0; Data Source='" & currDbname & "'"
-
're-open the connection
-
con1.Open
-
'remove the mark-file
-
Call Kill "path to mark-file"
-
End Sub
-
...the new process must be: -
Private Sub cmdShowScore_Click()
-
If isExistingMarkFile Then
-
call updatingDataBase()
-
End If
-
score = getScoreFromDataBase()
-
...
I disagree, not in principle, but with the way it's implemented. This sort of thing should be handled in the getScoreFromDataBase routine, not the user interface. In other words, you shouldn't have to check for the "mark file" in each button-click routine.
I disagree, not in principle, but with the way it's implemented. This sort of thing should be handled in the getScoreFromDataBase routine, not the user interface. In other words, you shouldn't have to check for the "mark file" in each button-click routine.
Let see, why did you need checking for mark-fle in getScoreFromDatabase()? Each time user hit the button, we call getScoreFromDataBase() one time. That mean, if i placed the check function outside or inside the getScoreFromDatabase(), the check function will be called each time for the hit button event.
If you have another way to reduce the frequently of check-function, maybe its better to place check-function inside getScoreFromDatabase().
But thats not the problem.You can place the check-function anywhere you like, but you should check for newer data each time user need display data, or the data will be old.
... But thats not the problem.You can place the check-function anywhere you like, but you should check for newer data each time user need display data, or the data will be old.
That's precisely my point. It should be "encapsulated" within the database lookup function, as a standard part of the process. Not something that the caller has to remember to check before calling the lookup.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Erencans |
last post by:
Hi to all,
I want to error handling in ASP. But i think that ASP is not enough for
error handling. I have got two chance.
1. I can prapare an error page and control throught IIS.
2. I can use on...
|
by: Paul |
last post by:
I have an Access 2000 database with a form that is giving me some
major headaches. When you open the form, it displays all records and
allows editing, but has AllowAdditions set to False so that...
|
by: deko |
last post by:
I use this convention frequently:
Exit_Here:
Exit Sub
HandleErr:
Select Case Err.Number
Case 3163
Resume Next
Case 3376
Resume Next
|
by: Nathan Bloomfield |
last post by:
Hi there,
I am having difficulty with a piece of code which would work wonders
for my application if only the error trapping worked properly.
Basically, it works as follows:
- adds records...
|
by: windandwaves |
last post by:
Hi Gurus
Does anyone know how I set the error trapping to option 2 in visual basic.
I know that you can go to tools, options and then choose on unhandled errors
only, but is there a VB command...
|
by: Bill Stock |
last post by:
I have a subform which is causing a 3314 (Field can't contain a null value
because required is set to True) error. I solved this problem by trapping it
in the before update event. But then I...
|
by: Captain Nemo |
last post by:
I'm still using Office 2000 myself, but some of my clients have Office 2003.
I've recently added a piece of code to create an instance of Word, open a
document, fill in the blanks and become...
|
by: 47computers |
last post by:
Pretty new to PHP, I recently started learning about error trapping.
As of right now, I include the following into a page in my website:
-------BEGIN PASTE--------
error_reporting(E_ERROR |...
|
by: Elmo Watson |
last post by:
Up until now, I've done all the work (gui/front end programming, classes,
etc)
I've done all my error trapping (try/catch) in the methods in the code
behind.
Now I've got an opportunity to do...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
| |