473,667 Members | 2,577 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do I compress/repair access database from code?

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
Nov 13 '05 #1
7 5978
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The correct term is Compact & Repair. Use the DAO
"DBEngine.Compa ctDatabase" method.

This example is in VBA & from the Access VBA help file. Perhaps you can
translate to C++/OLEDb.

Sub CompactDatabase X()

Dim dbsNorthwind As Database

Set dbsNorthwind = OpenDatabase("N orthwind.mdb")

' Show the properties of the original database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End With

' Make sure there isn't already a file with the
' name of the compacted database.
If Dir("NwindKorea n.mdb") <> "" Then _
Kill "NwindKorean.md b"

' This statement creates a compact version of the
' Northwind database that uses a Korean language
' collating order.
DBEngine.Compac tDatabase "Northwind.mdb" , _
"NwindKorean.md b", dbLangKorean

Set dbsNorthwind = OpenDatabase("N windKorean.mdb" )

' Show the properties of the compacted database.
With dbsNorthwind
Debug.Print .Name & ", version " & .Version
Debug.Print " CollatingOrder = " & .CollatingOrder
.Close
End With

End Sub

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQXrcFYechKq OuFEgEQLYUwCgzd V2bvnf+cgWDEHuD rF0xgLmXeIAn3af
k6AXGDumADY4P43 Oy7vx7b59
=o5LA
-----END PGP SIGNATURE-----
Riley DeWiley wrote:
Subject says it all. I am writing in C++/OLEDB and want to compress + repair
from my program, what do I have to do?


Nov 13 '05 #2
Neither C++ nor OLEDB has the innate ability to compact & repair, so you'll
need a reference to another library.
If your users will have Access installed on their machines, you can use the
DAO solution posted.
However, to my knowledge the DAO library itself is not freely distributable.
It's my understanding that the JRO library is both freely distributable and
smaller than the DAO library.
What I don't know is how well it works from C++ -
but give it a try!
"Riley DeWiley" <ri***********@ gmail.com> wrote in message
news:10******** *****@corp.supe rnews.com...
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

Nov 13 '05 #3
Hi:

I am trying to use the code posted by MGFoster on this subject, but when I try and use it
I get an error "user-defined type not defined" on the first line ( Dim dbsNorthwind As
Database). I have modified other lines to refer to my database, and am a bit perplexed as
to why this is happening.

Can someone point me in the right direction please.

John Baker
Nov 13 '05 #4
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Access versions 2000, and higher, require a Reference to the DAO library
(VBA module, main menu: Tools > References). To Dim the variable, do it
this way:

Dim dbsNorthwind As DAO.Database

--
MGFoster:::mgf0 0 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQX1HToechKq OuFEgEQI98gCfd6 wYsQ/GaTswdwfJQgyP1e 91P70AoNtm
i8kKPNEjrjpz+89 OnlSAXktn
=XtxV
-----END PGP SIGNATURE-----
John Baker wrote:
Hi:

I am trying to use the code posted by MGFoster on this subject, but when I try and use it
I get an error "user-defined type not defined" on the first line ( Dim dbsNorthwind As
Database). I have modified other lines to refer to my database, and am a bit perplexed as
to why this is happening.

Can someone point me in the right direction please.


Nov 13 '05 #5
I dimly recall seeing a way you could pass an SQL "query" to a Jet backend
to get it to compact ... I have a hard time believing this is not possible
with the standard libs, it is almost impossible to even run access without
compacting every now and again ..

"MacDermott " <ma********@nos pam.com> wrote in message
news:lC******** *********@newsr ead3.news.atl.e arthlink.net...
Neither C++ nor OLEDB has the innate ability to compact & repair, so you'll need a reference to another library.
If your users will have Access installed on their machines, you can use the DAO solution posted.
However, to my knowledge the DAO library itself is not freely distributable. It's my understanding that the JRO library is both freely distributable and smaller than the DAO library.
What I don't know is how well it works from C++ -
but give it a try!
"Riley DeWiley" <ri***********@ gmail.com> wrote in message
news:10******** *****@corp.supe rnews.com...
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


Nov 13 '05 #6
Sorry, I don't think I've ever seen such SQL -
which of course doesn't mean it doesn't exist.
(Googling newsgroups can bring up a lot of treasures.)
I'm not sure what you mean by "the standard libs".
Not all the libraries which are part of a standard install of Access are
freely distributable.

Microsoft has a couple of articles on compacting using OLEDB:
http://support.microsoft.com/default...b;EN-US;230501
http://support.microsoft.com/kb/230496/EN-US/
using two different libraries (one of them JRO) from MDAC.

HTH
- Turtle
"Riley DeWiley" <ri***********@ gmail.com> wrote in message
news:10******** *****@corp.supe rnews.com...
I dimly recall seeing a way you could pass an SQL "query" to a Jet backend
to get it to compact ... I have a hard time believing this is not possible
with the standard libs, it is almost impossible to even run access without
compacting every now and again ..

"MacDermott " <ma********@nos pam.com> wrote in message
news:lC******** *********@newsr ead3.news.atl.e arthlink.net...
Neither C++ nor OLEDB has the innate ability to compact & repair, so

you'll
need a reference to another library.
If your users will have Access installed on their machines, you can use

the
DAO solution posted.
However, to my knowledge the DAO library itself is not freely

distributable.
It's my understanding that the JRO library is both freely distributable

and
smaller than the DAO library.
What I don't know is how well it works from C++ -
but give it a try!
"Riley DeWiley" <ri***********@ gmail.com> wrote in message
news:10******** *****@corp.supe rnews.com...
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



Nov 13 '05 #7
Come to think of it, I did turn this up, thanks:

http://support.microsoft.com/kb/230496/EN-US/
Nov 13 '05 #8

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

Similar topics

7
1962
by: Medved | last post by:
Hi, We have not a smallest access database (30 tables, 160 queries,35 forms,40 reports,15 pages) with some links to other databases and some sql queries from other databases.The databse is not using many advanced features and there are only about 15 simple macros. Recently we have a problem with a need to repair database (2 -4 times a week). What is even more alarming is that 2 times happend that even after repair we could not use...
4
3249
by: Brian | last post by:
Good morning, I have a client with an Access 2002 database that is giving an Error 3197 upon open (The Microsoft Jet database engine stopped the process because you and another user are attempting to change the same data at the same time.). The database is not used in a multiuser environment. I tried compacting through the built in utility in Access to no avail. I submitted the database to www.accessdatabaserepair.com (a 3rd party db...
3
5567
by: Paolo | last post by:
Hi, I am trying to compact and repair my database, however every time I try it comes up a message saying: Table: "TempMSysAccessObject already exists", whenever I try to look for this table I cannot find it anywhere... Any clues... Already went into the help file and nothing... Also try to copy my database and the same message comes up
14
25669
by: Lauren Wilson | last post by:
Well, it has finally happened. We have a five year old app that is widely distributed. I cannot get an update done because none of the code modules will open. Access complains that the module is corrupt or that it cannot be read from a network drive. They are not ON a network drive. Anyone have a clue how to repair this? All help much appreciated.
1
3640
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
11
4957
by: ritenah | last post by:
I am running this command from a .bat file. "C:\pathToAccess\MSACCESS.EXE" "C:\pathToDatabase\db.mdb" /REPAIR Database repairs as expected, then shows the messge: "Successfully repaired the ..." and you have to click "Ok" to get rid of the message so that the database can close. How does one suppress this message, so that the database shuts down
2
2779
by: Ron | last post by:
Hi All, Using WinXP pro/Access 2000. I have a database that's been used for about 5 months. Transferred lots of data from a dos based program, then the users have been using it for that 5 months. About 180000 records in one of the main files (maybe 25000 new since the dos conversion). Been having some speed issues crop up along the way (much faster to do same reports when I first transferred the data than now, with the new 25000...
9
3986
by: Ron | last post by:
New discovery. If I take a perfectly good database, and "compact/repair" on it with Access 2000 (seems to be at multiple sites--I've tried it with my system here, at another office on an entirely different network), it damages the file somehow. The user's machine that did the compact/repair can see the file fine. But any networked user can't get in. I can double click on a good database file from any user (over the network) and it...
3
2201
by: Bizmark | last post by:
Access2003, Windows XP Pro OEM user OS, Windows Sever 2000 server OS. Not-so-recently I inherited 3 Access DB's from another company merging with our own. Our own system works off of SQL server, but mainting these databases is critical to keeping the business running. 1 database in particular has been causing problems. Along the course we have had a few problems with random records corrupting (new and old) and Values within fields...
0
8365
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8883
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8788
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8646
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7390
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4200
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.