 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
jason Guest
|
Posted: Thu Feb 24, 2005 8:08 am Post subject: Not enough Parameters? |
|
|
Hi all,
I have written the following function to compact & repair my
MS Access database.
My problem is that I keep getting the following exception on the
V.CompactDatabase line saying "project blah.exe raised exception class EOleSysError with message 'Invalide number of parameters'"
Hope you can shed some light on this. The function is below:
Many thanks, Jason.
==========================
function TfrmMaintenance.CompactAndRepair(DB: string): Boolean; {DB = Path to Access Database}
var
v: OLEvariant;
begin
Result := True;
try
v := CreateOLEObject('JRO.JetEngine');
try
V.CompactDatabase('Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DB+';Mode=Share Deny None;Persist Security Info=false;Jet OLEDB:Database Password=xxxxxxx' +
'Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+DB+'x;Mode=Share Deny None;Persist Security Info=false;Jet OLEDB:Database Password=xxxxxxx');
frmMaintenance.lbStatus.Caption := 'Finished repairing database.';
Application.ProcessMessages;
// DeleteFile(DB);
// RenameFile(DB+'x',DB);
finally
V := Unassigned;
end;
except
Result := False;
end;
end;
|
|
| Back to top |
|
 |
jason Guest
|
|
| Back to top |
|
 |
Bas van Beek Guest
|
Posted: Fri Feb 25, 2005 9:12 am Post subject: Re: Not enough Parameters? |
|
|
jason wrote:
How about importing the type library 'Microsoft Jet and Replication
Objects'?
This way you get two new objects in your VCL, one being the JetEngine
which has the desired CompactDatabase function.
This has worked for me...
CopyDB := TJetEngine.Create(nil);
try
CopyDB.CompactDataBase(oldConnString, newConnString);
finally
FreeAndNil(CopyDB);
end;
Bas van Beek
|
|
| Back to top |
|
 |
jason Guest
|
Posted: Fri Feb 25, 2005 9:13 pm Post subject: Re: Not enough Parameters? |
|
|
Bas,
| Quote: |
How about importing the type library 'Microsoft Jet and Replication
Objects'?
This way you get two new objects in your VCL, one being the JetEngine
which has the desired CompactDatabase function.
This has worked for me...
|
I have, now I have the JetEngine & Replica components appearing on the ActiveX component palette.
But...still exactly the same problem? I don't know what I'm
doing wrong? It still says "EOleException class does not exist"
when I try the JE.CompactDatabase function.
Jason.
|
|
| Back to top |
|
 |
Bas van Beek Guest
|
Posted: Fri Feb 25, 2005 10:25 pm Post subject: Re: Not enough Parameters? |
|
|
| Quote: |
I have, now I have the JetEngine & Replica components appearing on the ActiveX component palette.
But...still exactly the same problem? I don't know what I'm
doing wrong? It still says "EOleException class does not exist"
when I try the JE.CompactDatabase function.
|
What if you use the ComObj unit in your uses clause... That unit
contains the EOleException class
|
|
| Back to top |
|
 |
jason Guest
|
Posted: Sun Feb 27, 2005 10:58 pm Post subject: Re: Not enough Parameters? |
|
|
Bas,
| Quote: | What if you use the ComObj unit in your uses clause... That unit
contains the EOleException class
|
I have this unit in my uses clause? This bug is killing me!!
Jason.
|
|
| Back to top |
|
 |
jason Guest
|
Posted: Mon Feb 28, 2005 5:27 am Post subject: Re: Not enough Parameters? |
|
|
Brian,
| Quote: | Your connection string is the problem
Try
V.CompactDatabase('Data Source='+DB +';Jet OLEDB:Engine Type=5'+';Jet
OLEDB:Database Password=xxxxxxxx'
,'Data Source='+'x.mdb;Jet OLEDB:Engine Type=5')
|
Your a champ, that fixed it!!! Thanks, this was killing me!!
Thanks for your help.
Jason.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|