473,385 Members | 1,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Compress Access DB

I would like to compress my Access database from within my VB6 Aplication I
am writing.

Anyone know how?

Comet
Nov 12 '05 #1
7 11852
If you mean compacting then the following code should do the trick:

Dim oAccess As Object
Set oAccess = CreateObject("Access.Application")
oAccess.CompactRepair "<source db>", "<dest db>", True
oAccess.Quit
Set oAccess = Nothing
--
Björn Holmgren
Guide Konsult AB

"Comet Developer" <de*******@comet-online.co.za> wrote in message
news:bl**********@ctb-nnrp2.saix.net...
I would like to compress my Access database from within my VB6 Aplication I am writing.

Anyone know how?

Comet

Nov 12 '05 #2
Yes sorry compact! One question...can <source db> and <dest db> be the same
file?
Thanks for the help!
Nov 12 '05 #3
Try DBEngine.CompactDatabase (DAO). The database must be closed.

--
PZ
Comet Developer wrote:
I would like to compress my Access database from within my VB6
Aplication I am writing.

Anyone know how?

Comet

Nov 12 '05 #4
No, you have to rename the files after compacting (or remove the source db
and rename the dest db).

--
Björn Holmgren
Guide Konsult AB

"Comet Developer" <de*******@comet-online.co.za> wrote in message
news:bl**********@ctb-nnrp2.saix.net...
Yes sorry compact! One question...can <source db> and <dest db> be the same file?
Thanks for the help!

Nov 12 '05 #5
Found a piece of code to do it on the MSDN site:

Dim jro As jro.JetEngine

Set jro = New jro.JetEngine

jro.CompactDatabase "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=d:\nwind2.mdb;Jet OLEDB:Database Password=test", _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\abbc2.mdb;Jet OLEDB:Engine
Type=4;Jet OLEDB:Database Password=test"

Nov 12 '05 #6
On Fri, 3 Oct 2003 08:27:11 +0200, "Comet Developer" <de*******@comet-online.co.za> wrote:

¤ I would like to compress my Access database from within my VB6 Aplication I
¤ am writing.
¤
¤ Anyone know how?

Access is not required for the following:

HOWTO: Compact Microsoft Access Database Through ADO
http://support.microsoft.com/default...b;en-us;230501
Paul ~~~ pc******@ameritech.net
Microsoft MVP (Visual Basic)
Nov 12 '05 #7
"Comet Developer" <de*******@comet-online.co.za> wrote in message news:<bl**********@ctb-nnrp2.saix.net>...
I would like to compress my Access database from within my VB6 Aplication I
am writing.

Anyone know how?


Bjorn's method requires the user to have Access on their machine, and
Zoltan's method requires you to be using DAO. My method requires none
of those. However, you may want to do some checking to find out what
version of odvccp32.dll the user needs, if everyone has it, what OS's
it's suppported on, etc. In my case, all machines will be Win2k, and
it works fine. I haven't done testing on WinXP.

By the way, I have NO idea where this came from, and I'm sorry to the
original person that I got this from. If anyone knows, please post
the author and I'll be sure to give them credit.
Private Declare Function SQLConfigDataSource Lib "odbccp32.dll" (ByVal
hwnd As Long, ByVal fRequest As Integer, ByVal cDriver As String,
ByVal cAttributes As String) As Boolean
Private Const ODBC_ADD_DSN = 1
Public Function CompactAccess(sDBPath, sNewPath, hSomeHandle As Long)
As Boolean
Dim bResult As Boolean
Dim sDriver As String
Dim sAttribute As String

' ----------------------------------------------------------
sDriver = "Microsoft Access Driver (*.mdb)"
' ----------------------------------------------------------

' ----------------------------------------------------------
' compact database
' ----------------------------------------------------------
sAttribute = "COMPACT_DB=""" & sDBPath & """ """ & sNewPath & """
General"
bResult = SQLConfigDataSource(hSomeHandle, ODBC_ADD_DSN, sDriver,
sAttribute)
' ----------------------------------------------------------

' ----------------------------------------------------------
CompactAccess = bResult
' ----------------------------------------------------------
End Function

And call it like this, from a form in my example:

If CompactAccess(sDBLocalPath, sDBLocalPath, Me.hwnd) = False Then
' Compact didn't work -- what reasons would cause this?
End If
Nov 12 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tony | last post by:
Hello, Any assistance would be appreciated: As the subject suggests I am trying to gunzip files using the Compress::Zlib module. The following is basically the code that I am working with: ...
7
by: Riley DeWiley | last post by:
Subject says it all. I am writing in C++/OLEDB and want to compress + repair from my program, what do I have to do? Thanks, RDeW
1
by: Herbert Wildmeister via .NET 247 | last post by:
Does anybody know a way to compress and decompress AVI videofiles in C# .NET using all installed video codecs? I've foundthe Video Compression Manager and a class wrapper for C++ but noCLS compliant...
1
by: Venkatesha R | last post by:
Hi, How to compress and repair access database in c#.net ? Please specify the dll's which are necessary to do these opertions. Thanks, venkatesha R
1
by: Marc Jennings | last post by:
Hi there, I have a problem in that I need to de-compress a file that was compressed using the UNIX compress command. The resulting filename is helloworld.xml.Z I have looked at SharpZipLib,...
6
by: Champika Nirosh | last post by:
Hi, I have two machine where I needed to have a extended TCP/IP protocol to make the link between the two machines Mean,I need to write a application that compress every data the machine send...
8
by: Narayanan G V | last post by:
Hi..., I am facing a problem with the Access database file once the size reaches 2GB (Access 2K)... Is there a VBA code which can enable the file to compress itself automatically when I complete...
5
by: zgh1970 | last post by:
Hi, Friends, default DB2 compression library. I am wondering if this option will have any new restriction on RESTORE in the following. (Can I used that backup imsage for restore at the...
13
by: OldBirdman | last post by:
Access has an option for Compact on Close. Very good, as that should stop a major increase in size every time any .mdb file is used by Access. My question is, Is this safe? It used to be that I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.