 |

03-26-2004, 03:21 AM
|
|
Freshman
|
|
Join Date: Dec 2003
Location: Paradise
Posts: 27
|
|
Copying Database
|
Hi,
I want to copy a database, say "C:\Data\stuff.mdb" to "C:\Data\stuff2.mdb". However, I need to copy the database when it is open. I.e. my program uses the database, and then I need to copy it.
Is this possible? If so, how do I do it?
I have tried fileCopy but it won't work because the file can't be open. I also tried DBEngine.CompactDatabase but that has the same permission problems.
Any help would be appreciated,
Craig
|
__________________
"In the quiet words of the Virgin Mary...'"Come again?"'"
|

03-26-2004, 03:30 AM
|
 |
Centurion
|
|
Join Date: Jan 2004
Location: Bulgaria
Posts: 121
|
|
Code:
Dim MyConn As ADODB.Connection
Set MyConn = New ADODB.Connection
MyConn.ConnectionString = "your connection string "
MyConn.Open
MyConn.Execute ("INSERT INTO stuff2(fields1,fields2,...)SELECT fields1,fields2,.... from stuff ")
MyConn.Close
|
|

03-26-2004, 03:38 AM
|
|
Freshman
|
|
Join Date: Dec 2003
Location: Paradise
Posts: 27
|
|
|
Thank you for your quick reply.
Excuse me here, but does your code not copy fields within the same .mdb file? If I am wrong then I appologise.
Just to clear things up, I explicitly need two separate .mdb files, so that I can send one by FTP, then delete the temporary .mdb file.
BRgrds
|
__________________
"In the quiet words of the Virgin Mary...'"Come again?"'"
|

03-30-2004, 02:55 PM
|
|
Newcomer
|
|
Join Date: Mar 2004
Location: United Kingdom
Posts: 22
|
|
|
Have you tried killing the lock file? Not sure if it will work.
Kill YourDatabase.ldb
|
|

03-30-2004, 03:04 PM
|
 |
Cum Grano Salis
Retired Moderator * Guru *
|
|
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
|
|
|
No, the file must be closed. You can't copy an Access mdb while it is open. Through VB, you need to close your ADO or DAO connection to the database file, then attempt to copy it.
|
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
|

03-30-2004, 06:13 PM
|
 |
Contributor
|
|
Join Date: Apr 2002
Location: brgy Ginebra
Posts: 449
|
|
|
how about doing a back up of it?
|
|

03-31-2004, 06:34 AM
|
 |
Cum Grano Salis
Retired Moderator * Guru *
|
|
Join Date: Jul 2002
Location: Baltimore, Maryland
Posts: 14,636
|
|
|
No, same problem. You need to make sure that any DAO or ADO connection to your mdb file CLOSED before trying to copy your database, running a compact and repair, or any other type of maintance.
And, instead of using a standard fileCopy command, I would use the CopyFile API method. It is quick and returns an integer value so you know whether or not it was successful.
|
__________________
"Artificial Intelligence is no match for natural stupidity." ~unknown
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
|