Board index » delphi » TADOQuery and parameters

TADOQuery and parameters


2003-09-19 11:18:18 PM
delphi57
Hello everybody,
In runtime, if a give a generic SQL phrase to a TADOQuery (Execute
procedure for example), how can I set the parameters directions ? (I'm
using MS SQL server 2000)
The SQL phrase can be really different : some cases I have no
parameters, others cases only input parameters and other cases input and
output parameters. Since the SQL phrase comes from another process the
program don't know the direction of the parameters.
Per default TADOQuery sets pdInput as direction. In case of an output
direction, SQL server reports an error.
How can I do this ?
Thanks
Frédéric
 
 

Re:TADOQuery and parameters

Check out the help file for TParameter.AddParameter and it gives a good
example even shows direction...
 

Re:TADOQuery and parameters

Quote
In runtime, if a give a generic SQL phrase to a TADOQuery (Execute
procedure for example), how can I set the parameters directions ? (I'm
using MS SQL server 2000)
Either use
Parameters.refresh
or
Parameters.clear
and then create new parameters
 

Re:TADOQuery and parameters

Brian Bushay TeamB writes:
Quote
>In runtime, if a give a generic SQL phrase to a TADOQuery (Execute
>procedure for example), how can I set the parameters directions ? (I'm
>using MS SQL server 2000)

Either use
Parameters.refresh

or
Parameters.clear
and then create new parameters
--
Brian Bushay (TeamB)
XXXX@XXXXX.COM
Sorry, but my question wasn't precise enough ! At runtime I don't know
the direction of the parameters (It's a part of an multi-tiers server
and each call can be a different query with different parameters). The
problem is I know the parameters but not their directions. If the query
executes a stored procedure with output parameters I should set the
parameters with the right direction. But how can i guess the direction ?
I think I could get these informations asking the properties of the
stored procedure. But it is perhaps a bit complicated...
In this case I should rather use a TADOStoredProc component ?
Thanks
Frédéric
 

Re:TADOQuery and parameters

Quote

Sorry, but my question wasn't precise enough ! At runtime I don't know
the direction of the parameters (It's a part of an multi-tiers server
and each call can be a different query with different parameters). The
problem is I know the parameters but not their directions.
then you should be using Parameters.refresh instead of trying to create your own
parameters