Hola
Explicandolo con codigo:
Código Delphi
[-]
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] +')';
if(Length(grdDatos.Cells[10,iRenglon]) > 0) then
begin
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
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