Ver Mensaje Individual
  #2  
Antiguo 24-02-2016
Avatar de roman
roman roman is offline
Moderador
 
Registrado: may 2003
Ubicación: Ciudad de México
Posts: 20.269
Reputación: 10
roman Es un diamante en brutoroman Es un diamante en brutoroman Es un diamante en bruto
Bueno, eso sucede porque en el cuerpo del FOR, en lugar de usar la variable I usas SG.Row que nunca cambia. Por otro lado, no es necesario inicializar QTemp cada vez:

Código Delphi [-]
var
  i : integer;
begin
  QTemp.SQL.Clear;
  QTemp.SQL.Text := 'Insert Into FacturaItem (CodFactura, CodParte, Cantidad, Descripcion, Precio,'+
    'Total, Impuesto) Values '+
    '(:CodFactura, :CodParte, :Cantidad, : Descripcion, :Precio, :Total, :Impuesto)';

  for i := 1 to Sg.RowCount-1 do
  begin
    QTemp.Parameters.ParamByName('CodFactura').Value   := CodigoFact;
    QTemp.Parameters.ParamByName('CodParte').Value     := SG.Cells[0, i];
    QTemp.Parameters.ParamByName('Cantidad').Value     := SG.Cells[1, i];
    QTemp.Parameters.ParamByName('Descripcion').Value  := SG.Cells[2, i]; 
    QTemp.Parameters.ParamByName('Precio').Value       := SG.Cells[3, i]; 
    QTemp.Parameters.ParamByName('Total').Value        := SG.Cells[4, i]; 
    QTemp.Parameters.ParamByName('Impuesto').Value     := SG.Cells[5, i];
    QTemp.ExecSQL;
end;

LineComment Saludos
Responder Con Cita