Ver Mensaje Individual
  #3  
Antiguo 07-02-2005
lucianojdg lucianojdg is offline
Miembro
 
Registrado: dic 2003
Posts: 42
Reputación: 0
lucianojdg Va por buen camino
Perdón, no se que sucedio que quedo muy mal tabulado... lo reescribo para que sea legible.


El problema es que no estas manejando bien las transacciones:

Prueba con Esto:

// fDatos es un DataModule
// Server es el componente TDataBase
Código Delphi [-]
 if fDatos.Server.InTransaction then fDatos.Server.RollBack;
   fDatos.Server.StartTransaction;
 try 
   FClientes.QueryClientes.SQL.Clear; 
   FClientes.QueryClientes.SQL.Add('insert into clientes');     
   FClientes.QueryClientes.SQL.Add(' values (:codigo, :nombre, :dni, :nomb_comerc, :direccion;'); 
   FClientes.Queryclientes.ParamByName('codigo').AsString:= ECodigo.Text;   
   FClientes.Queryclientes.ParamByName('nombre').AsString:= ECliente.Text; 
   FClientes.QueryClientes.ParamByName('dni').AsString:= EDni.TExt; 
   FClientes.QueryClientes.ParamByName('nomb_comerc').AsString:= Enombcomer.text; 
   FClientes.QueryClientes.ParamByName('direccion').AsString:= Edirecc.text;   
   FClientes.Queryclientes.ExecSQL; fDatos.Server.Commit;
 except
   if fDatos.Server.InTransaction then
     fDatos.Server.Rollback; 
   
   MessageDlg('Se ha producido un error al intentar agregar el Cliente.', mtError, [mbOK], 0); 
 end;
 
 FClientes.QueryClientes.SQL.Clear;
 FClientes.QueryClientes.SQL.Add('select * from clientes');
 // FClientes.QueryClientes.Close; no es necesario cuando haces un clear
 FClientes.QueryClientes.Open;

Saludos
__________________
Luciano DG

Última edición por marcoszorrilla fecha: 07-02-2005 a las 15:36:42.
Responder Con Cita