graga
asked on
Passing parameters to ADODataSet
I have a problem to retrieve the record from ADODataSet by changing its parameters:
Scenario:
ADODataSet of CommandType cmdStoredProc is connected to Access2000 query.
Query is a simple:
SELECT * FROM CLIENT WHERE CODE = [:INVALUE]
I open the query with:
with qryClient do begin
Close;
Parameters.Items[0].Value := sCode;
Open;
end;
When I assign value to the Parameters[0] of the dataset, everything works correct for the first time. However every subsequent assigning of parameter value does not locate the correct record.
i.e.
Calling for the first time with Code='A' the query retrieves 'Client A'
Calling next time with code='B' will still return 'Client A'
I realise that using 'locate' or 'filter' on full client query would be a solution, but in my case qryClient is required to hold only one record
Scenario:
ADODataSet of CommandType cmdStoredProc is connected to Access2000 query.
Query is a simple:
SELECT * FROM CLIENT WHERE CODE = [:INVALUE]
I open the query with:
with qryClient do begin
Close;
Parameters.Items[0].Value := sCode;
Open;
end;
When I assign value to the Parameters[0] of the dataset, everything works correct for the first time. However every subsequent assigning of parameter value does not locate the correct record.
i.e.
Calling for the first time with Code='A' the query retrieves 'Client A'
Calling next time with code='B' will still return 'Client A'
I realise that using 'locate' or 'filter' on full client query would be a solution, but in my case qryClient is required to hold only one record
ummmm im only new to delphi but have you tried resetting the variable before you run through the second time ?????
ummmm im only new to delphi but have you tried resetting the variable before you run through the second time ?????
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Epsylon,
Thanx again.
I just had to insert:
ADODataSet1.Parameters.Ref resh
before your code and everything is working fine now.
Thanx again.
I just had to insert:
ADODataSet1.Parameters.Ref
before your code and everything is working fine now.
glad to hear that and thanks for the points graga
:o)
:o)