How to close all access to the Access Database in VB6?..

Philippines
October 17, 2010 9:02pm CST
I recently made an application in which I made this feature "BackUp Data" wherein I used the filecopy mechanism "FileCopySource,Destination"..The only problem is that this code will have an error if the database in in use..And it's used by the most of the forms if loaded..I put a code wherein in all Form_Unload events.."db.Close" so that any set access to the database is closed..But still, there's something still acessing the database.. Do you know any code which will close any active process that is accessing the Access database?..Or any method that will pinpoint which code or form is accessing the dababase?..Any help would be greatly appreciated..Thanks..
4 responses
@sais06 (1284)
• Philippines
12 Aug 11
Hi geniusvinz! I have already done that program several times now. That was also my problem the first time I tried to create a database backup. I think that "db.close" is your connection from VB to Access. Just closing the connection, I believe won't work. Usually we have objects used to access the database, like say for example recordsets. If you have used this code or familiar with this one: rs.open or recset.open then you have to close it first. Just use, "rs.close" or "recset.close". Alternatively, you may use, Set rs = nothing or Set recset = nothing If you have used Adodc to connect the database then you have to close all of those on all of the forms you have used. On the Form_Unload events, use Adodc1.ConnectionString = "" Hope this helps.
@sais06 (1284)
• Philippines
12 Aug 11
Hi geniusvinz! I have already done that program several times now. That was also my problem the first time I tried to create a database backup. I think that "db.close" is your connection from VB to Access. Just closing the connection, I believe won't work. Usually we have objects used to access the database, like say for example recordsets. If you have used this code or familiar with this one: rs.open or recset.open then you have to close it first. Just use, "rs.close" or "recset.close". Alternatively, you may use, Set rs = nothing or Set recset = nothing If you have used Adodc to connect the database then you have to close all of those on all of the forms you have used. On the Form_Unload events, use Adodc1.ConnectionString = "" Hope this helps.
@mlhervas (482)
• Philippines
18 Oct 10
Try to trace the code from the point where you place the code "db.Close". But a break there and then trace it line per line by pressing F8 until you get the error message. One possible cause that I suspect is that there is a point, in your code from somewhere between the "db.close" to the "backup process" (where the error is), when the database might have been opened again. Just try it. Good luck!
@sais06 (1284)
• Philippines
12 Aug 11
Hi geniusvinz! I have already done that program several times now. That was also my problem the first time I tried to create a database backup. I think that "db.close" is your connection from VB to Access. Just closing the connection, I believe won't work. Usually we have objects used to access the database, like say for example recordsets. If you have used this code or familiar with this one: rs.open or recset.open then you have to close it first. Just use, "rs.close" or "recset.close". Alternatively, you may use, Set rs = nothing or Set recset = nothing If you have used Adodc to connect the database then you have to close all of those on all of the forms you have used. On the Form_Unload events, use Adodc1.ConnectionString = "" Hope this helps.