Ver Mensaje Individual
  #1  
Antiguo 23-10-2007
Avatar de Gaim2205
Gaim2205 Gaim2205 is offline
Miembro
 
Registrado: ago 2007
Ubicación: Durango, Mexico
Posts: 144
Reputación: 17
Gaim2205 Va por buen camino
ADO, problema con commit

tengo mi aplicacion con d7, sql server 2000, y me conecto con los ADO, pero por mas commits que le doy, el insert o update solo tiene efecto hasta la proxima vez que inicio la aplicacion. La verdad nunca habia utilizado los ADO asi que muy probablemente estoy poniendo mal el begintrans y commit trans.

aqui esta el codigo, ojala me puedan ayudar. Gracias

Código Delphi [-]
begin
ADOConnection1.BeginTrans;
valida();
if valida = true then
begin
ds_precios.DataSet.Locate('combo',combo,[]);
fcombo := ds_precios.DataSet.fieldByName('combo').AsInteger;
fdate := ds_precios.DataSet.fieldByName('fecha').AsDateTime;
if (fcombo = combo) and (fdate = fecha.Date) then
begin
        showmessage(IntToStr(combo));
        pre := ds_precios.DataSet.FieldByName('precio').AsFloat;
        opc := MessageDlg('Este producto está registrado en la misma fecha con el precio: '+FloatToStr(pre)+' ,Sobreescribir?',mtWarning, mbOKCancel, 0);
        if opc = mrCancel then BitBtn2.Click
        else
        with que_fecha do begin
           with Parameters do begin
          ParamByName('price').Value := StrToFloat(precio.Text);
          ParamByName('combo').Value := combo;
          Parameters.ParamByName('date').Value := fecha.Date;
          end;
          ExecSQL;
          ADOConnection1.CommitTrans;
          ADOQuery1.Close; ADOQuery1.Open;
          DBGrid1.Refresh;
          especie.Text := ''; espesor.Text := '';
          clase.Text := ''; precio.Clear;
          fecha.Clear;
          end; end
else
begin
 showmessage(IntToStr(combo));
        showmessage(fecha.Text);
que_captura.SQL.Clear;
que_captura.SQL.Add('select count(id) from pocapprc_sql');
que_captura.Open;
gen_id := que_captura.Fields[0].AsInteger;
gen_id := gen_id+1;
with que_captura do begin
sql.Clear;
sql.Add('insert into pocapprc_sql(id,precio,fecha,combo)');
sql.Add('values(:id,recio,:fecha,:combo)');
with Parameters do begin
ParamByName('id').Value := gen_id;
ParamByName('precio').Value := StrToFloat(precio.Text);
ParamByName('fecha').Value := fecha.Date;
ParamByName('combo').Value := combo;
end;
ExecSQL;
ADOConnection1.CommitTrans;
ADOQuery1.Close; ADOQuery1.Open;
DBGrid1.Refresh;
especie.Text := ''; espesor.Text := '';
clase.Text := ''; precio.Clear;
fecha.Clear;
end; end; end
    else
      MessageDlg('Favor de introducir todos los datos',mtWarning, [mbOK], 0);
end;
Responder Con Cita