I am using SQL-DMO from VB to backup a database on a remote server.
However when I backup the database 2 times in a row, the first time the backup file is created OK, the 2nd time the database is not backed up. This appears to be because it won't write over the existing file.
I have experimented with the SQLDMO.Backup object's expirationdate property but this does not seem to be any help. Why is this happening?
Can anybody help?
'(m_SQLServer = previously defined ValidServer)
Try not setting the m_Backup.ExpirationDate and see what happens. I think that the value of VB NOW is today's date (ie. 28-Feb-2002) and from what I've read in BOL the backup will only over write files that are older. So if you perform this code twice in one day the job will fail on the second time.
The ExpirationDate property is valid only for backup data stored on disk or tape devices. Backup sets older than the expiration date can be overwritten by a later backup.
Thansk for your reply. However not setting an expiration date seems to have the same effect.
I have tried not setting the expiration date, setting it to the current date, and setting it to an older date. But the result is always the same. I wonder if it is a red herring, and the problem is with overwriting a backup on a remote machine.