gwarguitar
asked on
Compact / Repair MS Access DB
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!
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!
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
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
ASKER
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.
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.
ASKER
try this
-------------------Source- ---------- ---------- ---
procedure RepairCompact;
var
MdbFile: string;
DB: OLEVariant;
Temp: string;
begin
Screen.Cursor := crHourGlass;
try
MdbFile := copy(DataModule.adoconnect ion1.Conne ctionStrin g,
pos('Data Source=', DataModule.adoconnection1. Connection String)+12 ,
length(DataModule.adoconne ction1.Con nectionStr ing)-(pos( 'Data Source=', DataModule.adoconnection1. Connection String)+12 ));
MdbFile := copy(MdbFile, 1, pos(';',MdbFile)-1);
try
DataModule.ADOConnection1. Close;
DataModule.ADOConnection1. Connected := False;
DB := CreateOLEObject('DAO.DBEng ine.35');
// Repair
DB.RepairDataBase(MdbFile) ;
// Compact
Temp := ExtractFilePath(MdbFile) + 'Temp.mdb';
DB.CompactDataBase(MdbFile , Temp);
DeleteFile(MdbFile);
RenameFile(Temp, MdbFile);
Application.MessageBox('Do ne!.', 'Message', mb_IconInformation);
except
on E: Exception do Application.MessageBox(PCh ar(E.messa ge), 'Dao Error', mb_IconError);
end;
finally
DataModule.ADOConnection1. Open;
DataModule.ADOConnection1. Connected := True;
Screen.Cursor := crDefault;
end;
end;
-------------------Source-
procedure RepairCompact;
var
MdbFile: string;
DB: OLEVariant;
Temp: string;
begin
Screen.Cursor := crHourGlass;
try
MdbFile := copy(DataModule.adoconnect
pos('Data Source=', DataModule.adoconnection1.
length(DataModule.adoconne
MdbFile := copy(MdbFile, 1, pos(';',MdbFile)-1);
try
DataModule.ADOConnection1.
DataModule.ADOConnection1.
DB := CreateOLEObject('DAO.DBEng
// Repair
DB.RepairDataBase(MdbFile)
// Compact
Temp := ExtractFilePath(MdbFile) + 'Temp.mdb';
DB.CompactDataBase(MdbFile
DeleteFile(MdbFile);
RenameFile(Temp, MdbFile);
Application.MessageBox('Do
except
on E: Exception do Application.MessageBox(PCh
end;
finally
DataModule.ADOConnection1.
DataModule.ADOConnection1.
Screen.Cursor := crDefault;
end;
end;
ASKER
what unit is datamodule in?
Datamodule is the datamodule NAME
LOL
File->New->DataModule
It's Like a Form for databases objects
Have Fun :D
LOL
File->New->DataModule
It's Like a Form for databases objects
Have Fun :D
ASKER
oh i see, i've never messed with these before.. hmm.
it doesn't seem to know what adoconnection1 is though...
it doesn't seem to know what adoconnection1 is though...
Adoconnection is a component that u use to create Db Connection u can find it in the ADO palete on delphi....
ASKER
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...
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...
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
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
ASKER
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
just a form, button (repair db)
on button click openFileDialog and select ms access db (97) then do the compact/repair
just a form and a button? ok
Need Your email
Need Your email
ASKER
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
i don't think we're allowed to collaborate via email
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
that one worked mnasman!
the ado one...
is there any way to add a progress bar to that?
the ado one...
is there any way to add a progress bar to that?
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
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
if the solution that I gave you worked fine with you, why you gave me :B: grade??? :-(
ASKER
ooops! sorry. I was just crusing through there!
You could post on the Community Support to adjust the grade
https://www.experts-exchange.com/Community_Support/
https://www.experts-exchange.com/Community_Support/
Thanks a lot :-)
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...