macro to permanently delete a database

4 posts / 0 new
Last post
avikerem's picture
avikerem
Offline
Joined: 04/07/2015 - 00:28
macro to permanently delete a database

Hi Brian - how do you permanently delete a database in a macro? iIE  - is there a parameter to client.deletedatabase  or some other trick to permanently remove the database . THANKS

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Avi,

Actuall that is it:

Client.DeleteDatabase "Sample-DBASE.IMD"

You need to make sure the database is closed before deleting just like in IDEA so usually I have the:

Client.CloseAll

Client.CloseDatabase "Sample-DBASE.IMD"

command before I use the delete database, that way I know the database is closed.  You also have to make sure that if you have used it in an open function like:

Set db = client.OpenDatabase("Sample-DBASE.IMD")

that you have the

Set db = Nothing

before trying to delete it or else it won't work.

Hope that helps out.

Brian

jmax6
Offline
Joined: 04/12/2021 - 08:17

Regards Bryan
I am trying to perform this function of deleting a db, created for a single purpose, but I always get the same error.

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi jmax6,

My guess it that you haven't set the db variable to nothing.  This is one instance if you don't set the db variable to nothing then IDEA thinks the database is still in use even if the script is complete and you won't be able to delete or rename the file.

Instead of Set dbName = nothing it should be Set db = nothing

I think that should fix your problem.