Board index » delphi » TAdoDataSet - "CommandText does not return a result set" error

TAdoDataSet - "CommandText does not return a result set" error


2005-06-09 04:49:33 AM
delphi209
I have a TAdoDataSet (dstRptTemp) that I am setting up in code with a stored
procedure for handling report data.
The CommandType property is set to cmdStoredProc.
Here's my code:
dstRptTemp.Active := false;
dstRptTemp.CommandText := 'sp' + sReportName + ';1'; //sReportName is the
name of the report the user wants to run (the backend procedure has the same
name with an 'sp' prefix)
dstRptTemp.Parameters.Clear;
(* Set up parameters depending on which report was run. *)
if slParamPages.IndexOf(tbShtActiveStatus.Name) <>-1 then // parameters
are set by the user on various pages of a page control depending on the
report being run.
dstRptTemp.Parameters.CreateParameter('sActive', ftString, pdInput, 1,
radGrpActiveStatus.EditValue);
if slParamPages.IndexOf(tbShtCustOrVend.Name) <>-1 then
dstRptTemp.Parameters.CreateParameter('sCustOrVend', ftString, pdInput,
1, radGrpCustOrVend.EditValue);
dstRptTemp.Prepared := true;
dstRptTemp.Active := true;
Everything runs fine until the last line where I get an error "dstRptTemp:
CommandText does not return a result set."
Now this does work if I set it all up manually in the properties. If I set
up the paraemters and set Active = true I can view the report from the
design environment. So I know my stored procedure is fine. The only
difference I can see is that there is another parameter "@RETURN_VALUE" that
is automatically put in when I do it manually. I have no need for this and
do not have one set up in the stored procedure itself.
Any ideas as to what would cause this error?
Thanks,
Keith
 
 

Re:TAdoDataSet - "CommandText does not return a result set" error

Yes it returns a record set. it is the data source of a report.
I did what you suggested and used refresh and not clear. Also needed to do
"ParamByName" rather than "CreateParameter" and all is good so far.
Keith
"Brian Bushay TeamB" <XXXX@XXXXX.COM>writes
Quote
Everything runs fine until the last line where I get an error "dstRptTemp:
CommandText does not return a result set."

Now this does work if I set it all up manually in the properties. If I set
up the paraemters and set Active = true I can view the report from the
design environment. So I know my stored procedure is fine. The only
difference I can see is that there is another parameter "@RETURN_VALUE"
that
is automatically put in when I do it manually. I have no need for this and
do not have one set up in the stored procedure itself.

Any ideas as to what would cause this error?
Does you stored procedure return a recordset? If not you should be using
TadoCommand.
Otherwise try just
Adodataset1.Parameters.refresh;
instead of clearing and creating your parameters