Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Varios
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 24-02-2016
Avatar de Edwardfeliz
Edwardfeliz Edwardfeliz is offline
Miembro
 
Registrado: abr 2014
Posts: 102
Poder: 11
Edwardfeliz Va por buen camino
No me recore el string Grind y me ingresa la misma linea

Saludos,
No me recore el string Grind y me ingresa la misma linea las mismas veces que el la cantidad de lineas.
Este es el codigo.
Código Delphi [-]
var
i : integer;
Begin
For i := 1 to Sg.RowCount-1 do
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)';
QTemp.Parameters.ParamByName('CodFactura').Value   := CodigoFact;
QTemp.Parameters.ParamByName('CodParte').Value     := SG.Cells[0, SG.Row];
QTemp.Parameters.ParamByName('Cantidad').Value     := SG.Cells[1, SG.Row];
QTemp.Parameters.ParamByName('Descripcion').Value  := SG.Cells[2, SG.Row]; 
QTemp.Parameters.ParamByName('Precio').Value       := SG.Cells[3, SG.Row]; 
QTemp.Parameters.ParamByName('Total').Value        := SG.Cells[4, SG.Row]; 
QTemp.Parameters.ParamByName('Impuesto').Value     := SG.Cells[5, SG.Row];
QTemp.ExecSQL;
end;

Quiero que me agregue cada linea del string grid a la tabla de forma independiente.
Chao
Responder Con Cita
  #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
Poder: 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
  #3  
Antiguo 24-02-2016
Avatar de Edwardfeliz
Edwardfeliz Edwardfeliz is offline
Miembro
 
Registrado: abr 2014
Posts: 102
Poder: 11
Edwardfeliz Va por buen camino
:p

Gracias
Responder Con Cita
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Columnas de consulta en una misma linea oscarac SQL 1 02-07-2011 18:23:43
Datos en la misma Linea de un Memo RoyTan Varios 7 26-01-2008 01:53:58
Sumar montos a medida que se ingresa Analia29 Varios 6 27-10-2006 13:34:56
Varios INSERT en la misma línea. IPQ Firebird e Interbase 2 15-06-2006 22:07:21
Traspasar linea string Ricardo Alfredo Varios 2 19-11-2004 15:39:23


La franja horaria es GMT +2. Ahora son las 23:49:39.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi
Copyright 1996-2007 Club Delphi