473,383 Members | 1,818 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,383 software developers and data experts.

Copy Access Database without closing connections

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
6 11381
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
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
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
"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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: dustin lee | last post by:
Over the years I've gotten out of the habit of explicitly closing file objects (whether for reading or writing) since the right thing always seems to happen auto-magically (e.g. files get written...
0
by: Andrew Dowding | last post by:
Hi Everybody, I have been looking at problems with my Windows Forms C# application and it's little Jet 4 (Access) database for the last few days. The Windows Forms app implements a facade and...
14
by: Nick Gilbert | last post by:
Hi, I have an asp.net application which runs from a CD-ROM using Cassini. As such, it is single user only. The application connects to an Access database when it is loaded, and keeps the same...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
12
by: Hugh Welford | last post by:
hi Running an asp site on win/IIs/MSACCESS with a database reaching 45 meg. Responses seem a little slow. Could anyone provide a checklist of things to look at to optimise data access on this...
8
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query...
5
by: John | last post by:
I have an ASP.NET 2.0 application developed in VB.net, that accesses an Microsoft Access database. When the database is on the same IIS server all works just fine. BUT when it tried to access the...
5
by: Usman Jamil | last post by:
Hi I've a class that creates a connection to a database, gets and loop on a dataset given a query and then close the connection. When I use netstat viewer to see if there is any connection open...
2
by: Robin9876 | last post by:
In an ASP.Net v2 web application that connects to a SQL 2005 database. It appears that it is not closing the connections to the database and leaves 100 db connections open and then the application...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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.