By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,647 Members | 1,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,647 IT Pros & Developers. It's quick & easy.

Copy Access Database without closing connections

P: n/a
There should be a way to copy an access database ( .mdb file ) without
closing connections to it. Unfortunately the FileCopy statement in VB gives
an error if users are connected to the db. But I can copy the file using
windows explorer so there must be a way. WinAPI function or something?

I'm using VB6 and Access 2000

Nov 12 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Very bad idea, even if can find a way to do it. If there are active
connections, you have to assume there are tables and indexes not fully
updated, transactions in progress, or any number of activities that can
change the content of the database. If you copy the file at an arbitrary
moment you're likely to get an 'invalid format' error when you try to open
it.
"MAB71" <b1*********@yahoo.com> wrote in message
news:bo*************@ID-31123.news.uni-berlin.de...
There should be a way to copy an access database ( .mdb file ) without
closing connections to it. Unfortunately the FileCopy statement in VB gives an error if users are connected to the db. But I can copy the file using
windows explorer so there must be a way. WinAPI function or something?

I'm using VB6 and Access 2000

Nov 12 '05 #2

P: n/a
Use SHFileOperation

Maybe it's a bad idea to copy but sometimes you have no choice
(E.g. backup on a system that has [ideally] 100% uptime).

We use SHFileOperation to copy the MDBs during the night when 'all is
quiet'.
Such backups are usually OK.
Of course, if we can, we do close connections.

Bye,
Marius.


"Jezebel" <gr****@play.net> wrote in message
news:O4**************@TK2MSFTNGP10.phx.gbl...
Very bad idea, even if can find a way to do it. If there are active
connections, you have to assume there are tables and indexes not fully
updated, transactions in progress, or any number of activities that can
change the content of the database. If you copy the file at an arbitrary
moment you're likely to get an 'invalid format' error when you try to open
it.
"MAB71" <b1*********@yahoo.com> wrote in message
news:bo*************@ID-31123.news.uni-berlin.de...
There should be a way to copy an access database ( .mdb file ) without
closing connections to it. Unfortunately the FileCopy statement in VB

gives
an error if users are connected to the db. But I can copy the file using
windows explorer so there must be a way. WinAPI function or something?

I'm using VB6 and Access 2000


Nov 12 '05 #3

P: n/a
On Wed, 5 Nov 2003 21:36:59 +1100, "Jezebel" <gr****@play.net> wrote:
Very bad idea, even if can find a way to do it. If there are active
connections, you have to assume there are tables and indexes not fully
updated, transactions in progress, or any number of activities that can
change the content of the database. If you copy the file at an arbitrary
moment you're likely to get an 'invalid format' error when you try to open
it.


Agreed
- this is asking for really serious (and obscure) problems
Nov 12 '05 #4

P: n/a
"MAB71" <b1*********@yahoo.com> wrote in message news:<bo*************@ID-31123.news.uni-berlin.de>...
There should be a way to copy an access database ( .mdb file ) without
closing connections to it. Unfortunately the FileCopy statement in VB gives
an error if users are connected to the db. But I can copy the file using
windows explorer so there must be a way. WinAPI function or something?

I'm using VB6 and Access 2000


Use Arvin's KickEmOut routine, then backup the database or do
whatever. then let people back in. KickEmOut is at www.datastrat.com
in the downloads section.
Nov 12 '05 #5

P: n/a
On Wed, 5 Nov 2003 14:33:36 +0500, "MAB71"
<b1*********@yahoo.com> wrote:
in <bo*************@ID-31123.news.uni-berlin.de>
There should be a way to copy an access database ( .mdb file ) without
closing connections to it. Unfortunately the FileCopy statement in VB gives
an error if users are connected to the db. But I can copy the file using
windows explorer so there must be a way. WinAPI function or something?

I'm using VB6 and Access 2000


Public Declare Function CopyFile _
Lib "kernel32.dll" _
Alias "CopyFileA" ( _
ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
I've used this and had each workstation store a backup copy every
20 minutes. I've seen backups of corrupted databases but never a
corrupted backup. YMMV

Consider MSDE if it's at all possible.
Nov 12 '05 #6

P: n/a
"MAB71" <b1*********@yahoo.com> wrote in message news:<bo*************@ID-31123.news.uni-berlin.de>...
There should be a way to copy an access database ( .mdb file ) without
closing connections to it. Unfortunately the FileCopy statement in VB gives
an error if users are connected to the db. But I can copy the file using
windows explorer so there must be a way. WinAPI function or something?

I'm using VB6 and Access 2000


The expert warnings are probably valid but we've been doing it daily
for some years without apparent trouble. (We do warn other users that
we are about to do it and the edit/add transaction load is light)
From the frontend:
copy a blank mdb to the location you want to store the backup backend.
For each table in the backend:
DoCmd.TransferDatabase acImport....under a new name
DoCmd.TransferDatabase acExport...to the newly created backup backend,
with its correct name
DoCmd.DeleteObject acTable...the renamed table you just imported

Tony
Nov 12 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.