Hola giulichajari.
Lamento no tener
MySQL para tener la seguridad de que funcione en ese gestor, pero al ver la estructura de la tabla encontré dos detalles:
- El campo IDTICKET tiene la restricción NOT NULL y le envias NULL. (*)
- El campo IMPORTE esta declarado como INTEGER por lo que truncará los decimales, aún usando la propiedad AsFloat.
La prueba que hice (en
Firebird) y funciona correctamente es:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
var
idticket, numero, idsucursal: Integer;
importe: Double;
fechae,horae: string;
begin
idticket:= 1; numero:= 1;
idsucursal:= 1; importe:= 111.11;
fechae:= '04/08/2014';
horae := '10:19:00';
with TSQLQuery.Create(nil) do
try
SQLConnection:= SQLConnection1;
Close;
SQL.Clear;
SQL.Add('INSERT INTO TICKET (IDTICKET,NUMERO,IMPORTE,FECHAE,HORAE,IDSUCURSAL)');
SQL.Add('VALUES (:PID,:PNRO,:PIMP,:PFECHA,:PHORA,:PSUC)');
ParamByName('PID').AsInteger := idticket;
ParamByName('PNRO').AsInteger:= numero;
ParamByName('PIMP').AsFloat:= importe; ParamByName('PFECHA').AsString:= fechae;
ParamByName('PHORA').AsString:= horae;
ParamByName('PSUC').AsInteger:= idsucursal;
ExecSQL;
finally
Free;
end;
end;
(*) En Firebird enviar un valor nulo a un campo con restricción NOT NULL generaría un error de validación (desconozco si es igual en MySQL).
Espero te sirva de ayuda.
Saludos