Ver Mensaje Individual
  #5  
Antiguo 06-10-2010
Avatar de Caral
[Caral] Caral is offline
Miembro Premium
 
Registrado: ago 2006
Posts: 7.659
Reputación: 25
Caral Va por buen camino
Hola
Explicandolo con codigo:
Código Delphi [-]
  // inserto 7 campos
  SQL.Text:= 'INSERT INTO ventasareas '+
  ' (orden, articulo, codigo, descrip, cantidad, precio, tipo)'+
  ' VALUES('+IntToStr(iRenglon) + ',' + grdDatos.Cells[0,iRenglon] + ',' +
   grdDatos.Cells[1,iRenglon] + ',' + grdDatos.Cells[2,iRenglon] + ',' +
   grdDatos.Cells[3,iRenglon] + ',' + grdDatos.Cells[4,iRenglon] + ',' +
   grdDatos.Cells[6,iRenglon] +')';
   
   // Creo una condicion
   if(Length(grdDatos.Cells[10,iRenglon]) > 0) then
   begin
   // si se cumple inserto 8 campos
   SQL.Text:= 'INSERT INTO ventasareas '+
  ' (orden, articulo, codigo, descrip, cantidad, precio, tipo, categoria)'+
  ' VALUES('+IntToStr(iRenglon) + ',' + grdDatos.Cells[0,iRenglon] + ',' +
   grdDatos.Cells[1,iRenglon] + ',' + grdDatos.Cells[2,iRenglon] + ',' +
   grdDatos.Cells[3,iRenglon] + ',' + grdDatos.Cells[4,iRenglon] + ',' +
   grdDatos.Cells[6,iRenglon] + ',' + grdDatos.Cells[10,iRenglon] +')';
   end
   else
   begin
   // si no se cumple inserto 9 campos
    SQL.Text:= 'INSERT INTO ventasareas '+
  ' (orden, articulo, codigo, descrip, cantidad, precio, tipo, categoria, fecha)'+
  ' VALUES('+IntToStr(iRenglon) + ',' + grdDatos.Cells[0,iRenglon] + ',' +
   grdDatos.Cells[1,iRenglon] + ',' + grdDatos.Cells[2,iRenglon] + ',' +
   grdDatos.Cells[3,iRenglon] + ',' + grdDatos.Cells[4,iRenglon] + ',' +
   grdDatos.Cells[6,iRenglon] + ',' + grdDatos.Cells[10,iRenglon] + ',' +
   QuotedStr(grdDatos.Cells[15,iRenglon]) +')';
   end;
   ExecSQL;
   Close;
OJO hago ver que el dato fecha no coincidiría, pero asi es como lo tienes.
para mi se tendria que generar una condicion al inicio, de lo contrario hara el insert dos veces en este ejemplo.
Saludos
__________________
Siempre Novato
Responder Con Cita