Board index » delphi » ADO Stored Proc problem with Parameters

ADO Stored Proc problem with Parameters

We get an error when assigning values to our parameters of a Stored
Procedure. It says the first Parameter can not be found. It is perfect as in
the Stored procedure and it is assigned a valid value.

Does the standard rule of Opening and Closing a Stored procedure when using
a SELECT statement and also just using ExecProc when using an INSERT or
UPDATE statement apply in ADO? Is it required to set Active False and then
true rather.

Please shed some light for us on this because we are desperate in our effort
of converting to ADO Stored procedures from Std TADOQuery components because
all the rules we used before seems to have changed.

Here is the Stored Proc

Alter Procedure spILoad1
  @pID varchar(10),
  @pLOADTYPEID int,
  @pLOADDATE datetime,
  @pORIGINID varchar(10),
  @pDESTID varchar(10),
  @pCARRIERID varchar(10)

As

  INSERT INTO LOADS (ID, LOADTYPEID, LOADDATE, ORIGINID, DESTID, CARRIERID)
                                 VALUES (@pID, @pLOADTYPEID, @pLOADDATE,
@pORIGINID, @pDESTID, @pCARRIERID)

return

and the code where we call it

//  dmData.spILoad1.Active := false;  ???????????? is this required?
  dmData.spILoad1.Parameters.ParamByName('@pID').Value := ID;
  dmData.spILoad1.Parameters.ParamByName('@pLOADTYPEID').Value :=
dmData.tLocal['LOADTYPEID'];
  dmData.spILoad1.Parameters.ParamByName('@pLOADDATE').Value := now;
  dmData.spILoad1.Parameters.ParamByName('@pORIGINID').Value := 'NIS';
  dmData.spILoad1.Parameters.ParamByName('@pDESTID').Value :=
trim(Edit15.Text);
  dmData.spILoad1.Parameters.ParamByName('@pCARRIERID').Value :=
trim(DBLookupComboBox4.KeyValue);
  dmData.spILoad1.ExecProc;

 

Re:ADO Stored Proc problem with Parameters


Try removing the '@' in ParamByName
ie.
Quote
>   dmData.spILoad1.Parameters.ParamByName('pID').Value := ID;

Re:ADO Stored Proc problem with Parameters


try
 dmData.spILoad1.Parameters.refresh;
 dmData.spILoad1.Parameters.ParamByName('@pID').Value := ID;

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:ADO Stored Proc problem with Parameters


Are you sure about his, when I remove the @ I get a parameter error

Quote
Donna Chang <donna.ch...@centretech.com.au> wrote in message

news:3b2017e8_2@dnews...
Quote
> Try removing the '@' in ParamByName
> ie.
> >   dmData.spILoad1.Parameters.ParamByName('pID').Value := ID;

Other Threads