Log inUsernamePassword
Log me on automatically each visit    
Register
Register
Log in to check your private messages
Log in to check your private messages
Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting

Post new topic   Reply to topic
How Compact & Repair Database using Code ?
View previous topic :: View next topic  
Author Message
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Oct 18th, 2003 07:00 AM    Post subject: How Compact & Repair Database using Code ? Reply with quote

Hello!

Again as the subject says: How Compact & Repair Database using Code ?

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
pradeep
Newbie


Joined: 08 Oct 2003
Posts: 14
Location: INDIA

PostPosted: Oct 18th, 2003 11:59 AM    Post subject: Reply with quote

Code:

'DAO
DBEngine.CompactDatabase olddb, newdb [,locale [,options[,password]]]

'JRO
JetEngine.CompactDatabase(SourceConnection, DestConnection)
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Avis
Junior Poster


Joined: 07 Oct 2003
Posts: 510
Location: India

PostPosted: Oct 20th, 2003 04:16 AM    Post subject: Reply with quote

Hi!

I am not using DAO and JRO..i am using ADO. Hopw to do it for ADO ?

Thanks!
_________________
Code Snippets, Tutorials, Utilities, Controls

Low cost Web Hosting
Hosting starts at as low as $4 per year!


Always follow posting guidelines
Put your VB code in [vb ] your code [ /vb] tags!
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger ICQ Number
pradeep
Newbie


Joined: 08 Oct 2003
Posts: 14
Location: INDIA

PostPosted: Oct 20th, 2003 04:56 AM    Post subject: Reply with quote

Use JRO, not ADO, to compact a database.

JRO
Code:

Sub JROCompactDatabase()

   Dim je As New JRO.JetEngine

   ' Make sure there isn't already a file with the
   ' name of the compacted database.
   If Dir(".\NewNorthWind.mdb") <> "" Then Kill ".\NewNorthWind.mdb"

   ' Compact the database
   je.CompactDatabase "Data Source=.\NorthWind.mdb;", _
      "Data Source=.\NewNorthWind.mdb;"

   ' Delete the original database
   Kill ".\NorthWind.mdb"

   ' Rename the file back to the original name
   Name ".\NewNorthWind.mdb" As ".\NorthWind.mdb"

End Sub
Back to top
View user's profile Send private message Send e-mail MSN Messenger
rainster
Newbie


Joined: 04 Nov 2003
Posts: 4

PostPosted: Nov 4th, 2003 06:29 AM    Post subject: Reply with quote

Hi everyone!

I was wondering, will this code work without having MS Access actually installed on the computer it is run on?

Example: We use an application that uses a .mdb file for it's configuration, however, MS Access is not installed on that computer. From time to time, the .mdb file becomes corrupt and we have to delete the old .mdb and replace it with a known good/working copy.

Wouldn't it be nice to put a compact and repair program in the windows startup so that maybe the file wouldn't become corrupt?

Thanks in advance for any help with the issue.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
ritchieroo
Newbie


Joined: 27 Oct 2003
Posts: 8

PostPosted: Nov 4th, 2003 07:16 AM    Post subject: Reply with quote

The code should not need Access installed to run, and should work fine as long as you have the MDAC components installed.

Check VBA project references on target machines for ADODB, ADOX and JRO etc.
Back to top
View user's profile Send private message
rainster
Newbie


Joined: 04 Nov 2003
Posts: 4

PostPosted: Nov 4th, 2003 05:57 PM    Post subject: Reply with quote

Thanks Ritchieroo, I'll give it a try.

Now all I have to do is figure out if I want to hard code the path (cause its about 5-6 folders deep and hasn't changed in years) or use the apppath thingy and put my experiment in the same directory and drop the shortcut in the startup folder.

I'll post my success/failure later.

Thanks!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Visual Basic Forum for Visual Basic Programmers VB Forum Index » Database & Reporting All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Visual Basic Forum runs phpBB | Forum Template © iOptional
VB Resources | SSL | Visual Basic