Einzelnen Beitrag anzeigen

Rollo62

Registriert seit: 15. Mär 2007
3.926 Beiträge
 
Delphi 12 Athens
 
#2

AW: Delphi 10 Seattle Android 5.1 Unidac Connect SQLite nur manchmal erfolgreich

  Alt 23. Mai 2016, 17:42
Machst du soetwas beim Start ?

Das funktioniert für mich auf allen Plattformen.

EDIT:
Bei den Pfaden kann das natürlich in die Hose gehen wg. der Zugriffsrechte.
Deshalb habe ich Alles unter TPath.GetDocumentsPath abgelet.

Rollo

Delphi-Quellcode:
procedure TMeasuresDm.FDConnection1BeforeConnect(Sender: TObject);
var
  sFile: string;
  LStoragePath: TS4Storage_Path;

begin

    sFile := '';

    // Get Path+FileName
    LStoragePath := TS4Storage_Path.Create;
    try
      sFile := LStoragePath.FileIn_Documents_APP( CDb_Measure );

    finally
      LStoragePath.Free;
    end;

    FDConnection1.Params.Database := sFile;

end;


procedure TMeasuresDm.FDConnection1AfterConnect(Sender: TObject);
var
  sSQL: string;
  sFN: string;

begin

  //
  // Initial creation, if not already in place, remove the CopyOnStart DB
  //

  //###############
  // Data Table
  //###############
  sSQL := 'CREATE TABLE IF NOT EXISTS ' +
          'Measure (iId INTEGER PRIMARY KEY AUTOINCREMENT, ' +
                   'iType integer, ' +
                   'sText TEXT, '    +
                   'sDescr TEXT, '   +
                   'dRes REAL, dVal1 REAL, dVal2 REAL, dVal3 REAL, dCreated REAL, ' +
                   'sUnit TEXT)';

  FDConnection1.ExecSQL( sSQL ); //'CREATE TABLE IF NOT EXISTS Kunden (Name VARCHAR(100))');


  FDQueryMeasures.Active := True;

  if FDQueryMeasures.Active then
  begin
    ...
    ...
    ...
  end;

end;
  Mit Zitat antworten Zitat