Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Compacting work tables in vb

Posted on 2001-06-07
3
Medium Priority
?
216 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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

610 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