BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Not enough Parameters?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO)
View previous topic :: View next topic  
Author Message
jason
Guest





PostPosted: Thu Feb 24, 2005 8:08 am    Post subject: Not enough Parameters? Reply with quote




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





PostPosted: Fri Feb 25, 2005 5:00 am    Post subject: Re: Not enough Parameters? Reply with quote




Brian,

Quote:
I don't see a coma separating the two parameters that compactDatabase requires

Thanks, I did notice that after I posted. However, I am still having problems. See post below:
http://newsgroups.borland.com/cgi-bin/dnewsweb?cmd=article&group=borland.public.delphi.database.ado&item=51727&utag=

I hope you can help, it's frustrating the hell out of me!!
Cheers,
Jason.

Back to top
Bas van Beek
Guest





PostPosted: Fri Feb 25, 2005 9:12 am    Post subject: Re: Not enough Parameters? Reply with quote



jason wrote:
Quote:
Brian,


I don't see a coma separating the two parameters that compactDatabase requires


Thanks, I did notice that after I posted. However, I am still having problems. See post below:
http://newsgroups.borland.com/cgi-bin/dnewsweb?cmd=article&group=borland.public.delphi.database.ado&item=51727&utag=

I hope you can help, it's frustrating the hell out of me!!
Cheers,
Jason.

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





PostPosted: Fri Feb 25, 2005 9:13 pm    Post subject: Re: Not enough Parameters? Reply with quote


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





PostPosted: Fri Feb 25, 2005 10:25 pm    Post subject: Re: Not enough Parameters? Reply with quote

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





PostPosted: Sun Feb 27, 2005 10:58 pm    Post subject: Re: Not enough Parameters? Reply with quote


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





PostPosted: Mon Feb 28, 2005 5:27 am    Post subject: Re: Not enough Parameters? Reply with quote


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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (ADO) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.