?
Solved

Compacting work tables in vb

Posted on 2001-06-07
3
Medium Priority
?
213 Views
Last Modified: 2010-05-03
I am using access tables as work tables in VB6.
I am deleting records. Each time I run the program the DB gets larger by about 2MB. I do not want to have to have Access on the users machine so how do I compact the database so as to keep it from getting too big. I have used Access tables with VB6 apps before without having Access on the user machine but I did not notice this increase in the DB size.

I have tried dropping tables and then creating them when needed but this makes no difference.

Have the experts any ideas

Thanks
0
Comment
Question by:arquette2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 400 total points
ID: 6163026
Hi,

You can also use the CompactDatabase method of the Microsoft Jet and Replication Objects (JRO) 2.1 JetEngine
object to encrypt or decrypt a database. To use the JRO JetEngine object, you must set a reference to
the Microsoft Jet and Replication Objects 2.1 object library. When you use the CompactDatabase method,
you can't save the compacted (and optionally encrypted) database to the same name as the original database.
The CompactDatabase method takes two arguments to specify the source database and the destination database:
SourceConnection and DestConnection. Both the SourceConnection and DestConnection arguments take the
form of connection strings. Within the connection strings, you specify various connection properties
to determine how the source database is opened and how the destination database is compacted. At a minimum,
you must use the Data Source property in each connection string to specify the path and name of the
database. Additionally, to encrypt the database, you must include the Jet OLEDB:Encrypt Database property
in the connection string for the DestConnection argument. The following procedure uses these connection
properties to encrypt the database specified by the strSourceDB argument to the path and name specified
by the strDestDB argument:

Function EncryptDb(strSourceDB As String, _
                    strDestDB As String) As String
  Dim jetEngine          As JRO.JetEngine
  Dim strSourceConnect   As String
  Dim strDestConnect     As String

  ' Build connection strings for SourceConnection and
  ' DestConnection arguments.
  strSourceConnect = "Data Source=" & strSourceDB
  strDestConnect = "Data Source=" & strDestDB & ";" & _
                    "Jet OLEDB:Encrypt Database=True"

  Set jetEngine = New JRO.JetEngine

  ' Compact and encrypt the database specified by strSourceDB
  ' to the name and path specified by strDestDB.
  jetEngine.CompactDatabase strSourceConnect, strDestConnect

  Set jetEngine = Nothing
End Function
 

OR

http://www.freevbcode.com/ShowCode.Asp?ID=1024
0
 

Author Comment

by:arquette2
ID: 6163301
Thanks ryancys
Your answer works a treat.

I tried the free code but it did not work for some reason.

arquette2
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6163325
Hi arguette2, firstly glad can help you. and please pay tribute to TimCottee, one of the Expert in the Top 15 list. I get this code from what he posted earlier.

Then as compacting database, you can use DAO to do it so, find more about compact database in those VB website that may help. : )
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question