Invalid ParamType(Status=1h)

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Invalid ParamType(Status=1h)

Post by 99Percent » Tue 16 Feb 2010 05:38

UniSQL1 properties all default plus Connection string working properly.

Code: Select all

  with UniSQL1 do
  begin
    SQL.Clear;
    SQL.Add('INSERT tblPedidosHd2 (TiendaId,ClienteId,Tipo,PreviewsMes,Fecha,Usuario)');
    SQL.Add('VALUES(:TiendaId,:ClienteId,''A'',:PreviewsMes,GetDate(),:Usuario)');
    SQL.Add('SET :newid = SCOPE_IDENTITY()');
    ParamByName('TiendaId').AsInteger:=Tienda;
    ParamByName('ClienteId').AsInteger:=DBLookUpComboBox1.KeyValue;
    if Checkbox1.Checked then ParamByName('PreviewsMes').AsString:='D'+FormatDateTime('yymm',Date);
    ParamByName('Usuario').AsString:=GetCurrentUserName;
    ParamByName('newid').DataType := ftInteger;
    ParamByName('newid').ParamType:=ptInputOutput;
    Execute;
    PedidoId:=ParamByName('newid').AsInteger;
  end;
I get the following EOleDBError exception:

Code: Select all

Parameter[4]:newid - invalid ParamType(Status=1h).
Curiously I get the exception twice with the same Execute statement.

This type of insert code normally works perfectly now suddenly in this case its not working, any pointers?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 16 Feb 2010 09:51

To solve the problem try to change the following line:

Code: Select all

if Checkbox1.Checked then ParamByName('PreviewsMes').AsString:='D'+FormatDateTime('yymm',Date); 
to this code:

Code: Select all

if Checkbox1.Checked then 
  ParamByName('PreviewsMes').AsString:='D'+FormatDateTime('yymm',Date)
else
  ParamByName('PreviewsMes').AsString:='';

99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Post by 99Percent » Tue 16 Feb 2010 17:04

Thanks that fixed it.

I am embarrassed for my poor coding, leaving a parameter undefined. But still somewhere the error message is not coded right, no?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 17 Feb 2010 08:39

When parameter type is undefined, SQL Server returns error, that SDAC wraps to EOleDBError exception, and we don't change the error message.

Post Reply