Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Locked Database (Backup Troubles)

Status
Not open for further replies.

faztech

Programmer
May 21, 2001
22
AU
Hi,
I am developing a vb6 application with an Access 2000 backend(ADO). I am using com objects and have a function that will backup the database and save it with the date appended to it name in a sepeerate folder (i.e db01022001.mdb). I am using a file scripting object and just the copy file method. When I run this code I get a 'permission denied' error and it wont allow me to copy the database. I have changed the properites on the databse to stop locking but it does not seem to work. Someone once told me that you can unlock the database in code but I could not find this solution. If you have any ideas all will be helpful.

Thanks Always

Faztech FAZTECH
:p
 
Did you close your connection to the database before you tried to copy it?

scarfhead
 
Yeah thats the funny thing I dont even open it. I only ever open the database when I query or write to the database. So the database is actually closed. I have afunction in my DLL that opens and closes the database, So before I call a database function in the dll I call the openDB function and then after call Close DB. But I never open the db to perform this backup function because of obvious reasons I am also having trouble with the file scripting object. It is coming up as invalid procedure call. Here is the code
////////////////////////////////////////////////////////////

Const CurrDBPath = "..\Database\"
Const CurrDBName = "funkhouse.mdb"
Const BackupDBPath = "..\Database\Backup\"

Public Function BackupDatabase()
Dim backupDate As Date, backupDBName As String
Dim currdb As String
Dim FSO As Scripting.FileSystemObject

currdb = CurrDBPath & CurrDBName
backupDate = Format(Date, "dd/mm/yyyy")
backupDBName = BackupDBPath & CurrDBName & backupDate

If Len(Trim(Dir(backupDBName))) > 0 Then
BackupDatabase = False
Exit Function
Else
fs.CopyFile currdb, backupDBName, True
BackupDatabase = True
End If
End Function

///////////////////////////////////////////////////////

What do you think the problem is??

Thanks

Faztech FAZTECH
:p
 
from your code, backupDBName that you are trying to write to is (today) "..\Database\Backup\funkhouse.mdb10/05/2001"

Path not found. The slashes are going to cause some problems, as well as the file extension being in the middle of the file name.

I think you want ...funkhouse20011005.mdb as a filename. Year first guarantees chronological order for your backups.

Put in an error handler to verify that this the problem.

scarfhead
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top