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

x
?
Solved

Compact / Repair MS Access DB

Posted on 2004-04-13
22
Medium Priority
?
450 Views
Last Modified: 2010-04-05
I want to open a Microsoft Access Database (mdb)  on a machine (Win 95/Win 2000) that does not have MS Access (version 97) and perform a compact and repaid operation.

I've found a compnent that does this, but any time I try and do anything with it says "Invalid class string"
i'm trying to use it with delphi 6, and it says it's compatible with 3.

Is there any way to do this? Does the machine need Access installed on it?

Thanks!
0
Comment
Question by:gwarguitar
[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
  • 9
  • 5
  • 5
  • +2
22 Comments
 
LVL 11

Expert Comment

by:calinutz
ID: 10817900
Usually the computer needs to hace mdac components latest version from Microsoft installed. So you should try installing the MDAC 2.8 from
http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&displaylang=en
and if it does not work you shopuld specify the component you use to do the compacting and repairing of the MDB...
0
 
LVL 1

Expert Comment

by:ricswika
ID: 10817943
I'd also like to know how to run the Compact/Repair function from my code.

I noticed, the OBDC configure dialog offers the 'Compact' function on a button (without needing MS Access). Therefore, the functionality is provided, just how to access it?

Rick
0
 

Author Comment

by:gwarguitar
ID: 10818110
i'll try the mdac :)

this is the download to the component i tried
if it could be made to work with d6/d7 that would be great!

it's very light weight and does all i need it to.
0
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.

 

Author Comment

by:gwarguitar
ID: 10818117
oopps.. i'm stupid.. here's the link :)

http://torry.net/db/direct/ms_access/msautil.zip
0
 

Expert Comment

by:lnishimura
ID: 10818122
try this

-------------------Source------------------------
procedure RepairCompact;
var
MdbFile: string;
DB: OLEVariant;
Temp: string;
begin
Screen.Cursor := crHourGlass;
try
MdbFile := copy(DataModule.adoconnection1.ConnectionString,
pos('Data Source=', DataModule.adoconnection1.ConnectionString)+12,
length(DataModule.adoconnection1.ConnectionString)-(pos('Data Source=', DataModule.adoconnection1.ConnectionString)+12));
MdbFile := copy(MdbFile, 1, pos(';',MdbFile)-1);
try
DataModule.ADOConnection1.Close;
DataModule.ADOConnection1.Connected := False;

DB := CreateOLEObject('DAO.DBEngine.35');
// Repair
DB.RepairDataBase(MdbFile);
// Compact
Temp := ExtractFilePath(MdbFile) + 'Temp.mdb';
DB.CompactDataBase(MdbFile, Temp);
DeleteFile(MdbFile);
RenameFile(Temp, MdbFile);

Application.MessageBox('Done!.', 'Message', mb_IconInformation);
except
on E: Exception do Application.MessageBox(PChar(E.message), 'Dao Error', mb_IconError);
end;
finally
DataModule.ADOConnection1.Open;
DataModule.ADOConnection1.Connected := True;
Screen.Cursor := crDefault;
end;
end;
0
 

Author Comment

by:gwarguitar
ID: 10818357
what unit is datamodule in?
0
 

Expert Comment

by:lnishimura
ID: 10818383
Datamodule is the datamodule NAME
LOL

File->New->DataModule


It's Like a Form for databases objects


Have Fun :D
0
 

Author Comment

by:gwarguitar
ID: 10818437
oh i see, i've never messed with these before.. hmm.
it doesn't seem to know what adoconnection1 is though...
0
 

Expert Comment

by:lnishimura
ID: 10818478
Adoconnection is a component that u  use to create Db Connection u can find it in the ADO palete on delphi....
0
 

Author Comment

by:gwarguitar
ID: 10818528
ok i see.. yeah it compiles...

now what do i do with it?

basically, i want a form with a button that says 'repair db' when clicked it brings up open file dialog then select the mdb then run this thing...

0
 

Expert Comment

by:lnishimura
ID: 10818542
Ok i tell u what...
u tell me exacltly what i want and i do it for you!!!



Man i'm trying to watch friends!

dont forget your email address to sent the code
Lol
0
 

Author Comment

by:gwarguitar
ID: 10818551
what i want to have it do is exactly what i just said :)

just a form, button (repair db)
on button click openFileDialog and select ms access db (97) then do the compact/repair
0
 

Expert Comment

by:lnishimura
ID: 10818713
just a form and a button? ok


Need Your email
0
 

Author Comment

by:gwarguitar
ID: 10818718
just post it here. i know there is another guy above that wants the code as well :)
i don't think we're allowed to collaborate via email
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 1000 total points
ID: 10818802
Hello

  Look at this paq, and you will find two ways using ADO and DAO
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20244125.html
0
 

Author Comment

by:gwarguitar
ID: 10825233
that one worked mnasman!
the ado one...

is there any way to add a progress bar to that?
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 10831088
Hello

   I'm not sure of the JRO offers something like that, but you could try other ways like changing the cursor to busy one while compacting and when finish return it to the normal one, or try to use ProgressBar like the one used for searching in windows xp, which will be animated without counting from 1 to 100 for exmpale

try to  download TXProgress from torry site, and make the gradation Progressbar move till the compacting finish
http://www.torry.net/pages.php?id=504

HTH

Regards,
Mohammed
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 10866379
if the solution that I gave you worked fine with you, why you gave me :B: grade??? :-(
0
 

Author Comment

by:gwarguitar
ID: 10868921
ooops! sorry. I was just crusing through there!
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 10875386
You could post on the Community Support to adjust the grade
http://www.experts-exchange.com/Community_Support/
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 10885892
Thanks a lot :-)
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

636 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