Page 1 of 1

Invalid ParamType(Status=1h)

Posted: Tue 16 Feb 2010 05:38
by 99Percent
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?

Posted: Tue 16 Feb 2010 09:51
by Dimon
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:='';

Posted: Tue 16 Feb 2010 17:04
by 99Percent
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?

Posted: Wed 17 Feb 2010 08:39
by Dimon
When parameter type is undefined, SQL Server returns error, that SDAC wraps to EOleDBError exception, and we don't change the error message.