Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Conexión con bases de datos (https://www.clubdelphi.com/foros/forumdisplay.php?f=2)
-   -   append en lugar de post...???? (https://www.clubdelphi.com/foros/showthread.php?t=67584)

JuanchoDev 24-04-2010 02:40:54

append en lugar de post...????
 
hola gente, a ver si me pueden dar una manito
este form en lugar de modificar (adoqueryX.post) esta agregando nuevos registros, la verdad no le encuentro el error...


procedure TForm13.Modificar1Click(Sender: TObject);
begin
//buscar el id
adoquery2.Close;
adoquery2.SQL.Text:='select id from inventario where descripcion=:a and ubicacion=:b and fecha=:c';
adoquery2.Parameters.ParamByName('a').Value:=edit2.Text;
adoquery2.Parameters.ParamByName('b').Value:=edit3.Text;
adoquery2.Parameters.ParamByName('c').Value:=edit6.Text;
adoquery2.Open;

//modificar
adoquery3.Close;
adoquery3.SQL.Text:='SELECT id, descripcion, ubicacion, cuit_proveedor, numero_de_factura, fecha FROM inventario where id=:a';
adoquery3.Parameters.ParamByName('a').Value:=adoquery2.fields[0].asString;
adoquery3.Open;
adoquery3.Edit;
adoquery3.Fields[1].AsString:=edit2.Text;
adoquery3.Fields[2].AsString:=edit3.Text;
adoquery3.Fields[3].AsString:=edit4.Text;
adoquery3.Fields[4].AsString:=edit5.Text;
adoquery3.Fields[5].AsString:=datetostr(date)+' '+timetostr(time);
adoquery3.Post;

//edit1 es autonumerico

edit1.Text:='El sistema lo ingresa';
edit2.Clear;
edit3.Clear;
edit4.Clear;
edit5.Clear;
edit6.text:='El sistema lo ingresa';

//refresh
memo1.Text:='Recuerde que el "Libro de Inventario" debe ser actualizado manualmente y con letra manuscrita';
adoquery1.Close;
adoquery1.SQL.Text:='select inventario.id, inventario.descripcion, inventario.ubicacion, inventario.CUIT_PROVEEDOR, inventario.fecha, numero_de_factura from inventario';
adoquery1.Open;
dbgrid1.Columns[0].Title.caption:='Codigo de Inventario';
dbgrid1.Columns[1].Title.caption:='Descripcion';
//las ubicaciones tendrian que ser fk
dbgrid1.Columns[2].Title.caption:='Ubicación';
//los proveedores tendrian que ser fk
dbgrid1.Columns[3].Title.caption:='Proveedor';
dbgrid1.Columns[4].Title.caption:='Fecha';
dbgrid1.Columns[5].Title.caption:='Numero de factura';
dbgrid1.Columns[0].Width:=95;
dbgrid1.Columns[1].Width:=95;
dbgrid1.Columns[2].Width:=95;
dbgrid1.Columns[3].Width:=95;
dbgrid1.Columns[4].Width:=95;
dbgrid1.Columns[5].Width:=95;

end;

manuc 24-04-2010 08:34:26

Hola JuanchoDev,

Generalmente esto suele ocurrir, porque la consulta que está ejecutando con "adoquery3" no retorne ningún registro y se encuentra "empty". En este caso, al hacer un adoquery3.edit y no tener registro, el adoquery hace un .append, en vez de editar.

¿Podrías comprobar si en el momento de hacer adoquery3.edit, adoquery3 apunta al registro que quieres editar?

Un saludo.

JuanchoDev 25-04-2010 12:26:48

Ok!
 
solved!

gracias a todos/as!


La franja horaria es GMT +2. Ahora son las 16:07:07.

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