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!

Compacting secured Access97 database thru code

Status
Not open for further replies.

Ajb2528

Technical User
Feb 22, 2002
270
GB
I am trying (via VB6 SP5) to compact a secured (using system.mdw) Access97 database through VB6 code. Has anyone managed to do this? I have seen references to JRO (whatever that is!!) but cannot seen to access any of the references for JRO from within a VB project.

Any help would be appreciated!!

Regards,

Alan
 
If you have Access97 installed, you can do several cheap workarounds:

1. Run the command-line msaccess.exe with the document and the /compact option - extremely ugly


Hmm. Just checked these threads: this is where your answer is.

It looks like you register a "JRO.DLL" and use the "DBEngine.CompactDatabase" method. I don't know any of this from personal experience.



 
You might try this or something like this
docmd.runcommand acCmdCompactDatabase

Hope this helps
Hymn
 
It took me some time to work out this problem.
Like you I could not get any response to the JRO commands.
but I did it in the end.

To use jRO you need to add a reference to it.
Under references tick microsoft Jet and Replication objects 2.6 libary.
Then you can use the DBEngine.CompactDatabase command.

its a little tricky to use at first as you have to make a duplicate database and then delete the old one.

I now use it on all my datbase programs.
I could supply you a sample code for it if you need it.

Mick

 
Mick,
Thanks for the response...if you could, can you email the sample code please.

Email is: albates@quantumconsultinggroup.com

Regards,

Alan
 
Mick,

I think that I have solved the problem. Below is the code that I have used. I dont know whether its the same as yours but it appears to work!!! I would still be interested to see your code though!!

JRO.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strSrcDB & ";Jet OLEDB:Database Password=" & strPassword & ";Jet OLEDB:System Database=" & strSystemDb & ";User Id=AlanB;Password=bankrec", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDestDB & ";Jet OLEDB:Database Password=" & strPassword & ";Jet OLEDB:Engine Type=4;Jet OLEDB:System Database=" & strSystemDb & ";User Id=AlanB;Password=bankrec"


PS Sorry about the formatting!!

Regards,

Alan
 
Alan.

I have my doubts if your compact program works!

I think you will find that you will have to compact the database into a new temporary database then delete your original database, then rename the new database to its original name.
I have e-mailed you a sample program showing this.

mick
 
Mick,

The code snippet was just the JRO command. I have put in place the compact into a 'temp' database and the deleted the original and then renamed the 'temp' to the original mdb name....

Regards,

Alan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top