Ver Mensaje Individual
  #14  
Antiguo 09-04-2015
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Reputación: 15
AgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en brutoAgustinOrtu Es un diamante en bruto
Yo no me voy a cansar de decirlo

Una base de datos SQLite, con una simple tabla

Código Delphi [-]
type
  TConfigRecord = record
    TuDato1: Integer;
    TuDato2: string;
    TuDato3: boolean;
  end;  

procedure LoadConfig(var Config: TConfigRecord);
var
  FQuery: TFDQuery;
begin
  with FQuery.Create(NIL) do
  begin
    FQuery.Connection := SQLiteConn;
    FQuery.SQL.Text := ' SELECT * FROM Config ';
    Open;
    with Config do
    begin
       TuDato1 := FieldByName('Campo1').AsInteger;
       TuDato2 := FieldByName('Campo2').AsString;
       TuDato3 := FieldByName('Campo3').AsBoolean; 
    end; 
    Free;
  end;
end;

procedure SaveConfig(Config: TConfigRecord);
var
  FQuery: TFDQuery;
begin
  with FQuery.Create(NIL) do
  begin
    FQuery.Connection := SQLiteConn;
    FQuery.SQL.Text := ' UPDATE Config SET ' +
                       ' Campo1 = :Valor1, ' 
                       ' Campo2 = :Valor2, ' 
                       ' Campo3 = :Valor3 '; 
    with Config do
    begin
       ParamByName('Valor1').AsInteger:= Config.TuDato1;
       ParamByName('Valor2').AsString:= Config.TuDato2;
       ParamByName('Valor3').AsBoolean:= Config.TuDato3;
    end; 
    Execute;
    Free;
  end;
end;

Mayor simpleza, potencia y seguridad es imposible

Saludos
Responder Con Cita