Additional
dbCAP
AnyDAC
ThinDAC
NCOCI8
Topic: anydac TQuery as var parameter
anydac TQuery as var parameter
Posted: 2007/06/14 00:16
 
ah yes thank you very much.

how stupid of me, i was changing my project from BDE to AnyDAC and since i have several other project i totally forgot when i ran the conversion BDE2Any.exe i think i forgot that TQuery should be TADQuery he he he

anyway it's now compiled ok but unable to execute. an error message shows something like this:

"....connection or connectionName is not set" or blank or something i can't recall.

i've checked on the ADConnection it's been set, and all my TADQuery is set to the ADCOnnection

any ideas???

thank you very much in advance.

Post edited by: blur5, at: 2007/06/16 23:19
Re:anydac TQuery as var parameter
Posted: 2007/06/14 03:58
 
Hi.

I suppose you get an Access Violation exception...
The compiler should stop you before that, but a lot depends on how you pass the qry parameter.

The problem is you have declared a TQuery parameter, while you give the method a TADQuery pointer. TADQuery is NOT inherited from TQuery, so you cant do that

Easier solution is to change the parameter type to TADQuery.

If you want to make that method more generic (so it could work both with BDE and AnyDAC) you must change the qry parameter type to TDataSet and then check in the code what is passed, and act accordingly:


    if (qry is TQuerythen     TQuery(qry).ExecSQL   else     if (qry is TADQuerythen       TADQuery(qry).ExecSQL     else       raise Exception.Create('Invalid DataSet for the required operation');



You wont need the cast (this kind of code) for the .Open call, due to the fact that TDataSet has the Open method, and inheritance will assure the correct method will be called.

Hoping this helps you
Roby

Post edited by: pincopallo, at: 2007/06/14 04:05
Re:anydac TQuery as var parameter
Posted: 2007/06/16 23:13
 
ah yes, thank you very much

how stupid of me, i was changing the code from bde to anydac, and i forgot that the Tquery should be TADQuery he he he.

anyway, i managed to get it compiled, but there's another error something like this: "The connection or ConnectionName is not set" or is blank someting like that.

I've check the ADConnection1 and it's been set, and all my TADQuery connection already set to ADConnection1.

how do i solve this?

thank you very much in advance.
Re:anydac TQuery as var parameter
Posted: 2007/06/22 02:49
 
"....connection or connectionName is not set" or blank or something i can't recall.
If you getting this error, then some of your TADQuery / TADTable / etc does not have filled ConnectionName or Connection property. The most simple way to resolve issue will be -
- check Break On Exceptions in Delphi IDE;
- run your application from Delphi IDE up to the exception;
- check Call Stack View and find at which place in your application the exception is happen. That should give you idea, what is wrong.

Regards,
Dmitry
Re:anydac TQuery as var parameter
Posted: 2007/06/28 04:25
 
hi, thanks that works.