Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > OOP
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

Grupo de Teaming del ClubDelphi

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 09-04-2015
Avatar de AgustinOrtu
[AgustinOrtu] AgustinOrtu is offline
Miembro Premium
NULL
 
Registrado: ago 2013
Ubicación: Argentina
Posts: 1.858
Poder: 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
Respuesta



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
esta function no me funciona en XE2 y si funciona en D6 darkbits Varios 1 06-11-2012 17:00:45
UDF no funciona en xp GustavoCruz Firebird e Interbase 15 04-10-2011 12:07:00
funciona bien en windows 7 64b pero en XP no funciona ASAPLTDA Varios 5 06-05-2011 16:24:50
$L .Obj no funciona rastafarey Varios 2 09-01-2009 19:47:09
like no funciona ! dmasson Conexión con bases de datos 9 23-03-2004 14:10:50


La franja horaria es GMT +2. Ahora son las 20:42:26.


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
Copyright 1996-2007 Club Delphi