Code: Select all
procedure CreateDatabase;
var
Connection_Locale: TUniConnection;
Script_Local: TUniScript;
begin
Connection_Locale := TUniConnection.Create(nil);
Script_Local := TUniScript.Create(nil);
try
Script_Local.Connection := Connection_Locale;
Connection_Locale.ProviderName := 'SQLite';
Connection_Locale.Database := 'C:\Users\Public\Documents\SAS\Labels Printer\MyDB.DB3';
Connection_Locale.LoginPrompt := false;
Connection_Locale.SpecificOptions.Add('SQLite.ForceCreateDatabase=True');
Connection_Locale.SpecificOptions.Add('SQLite.Direct=True');
Connection_Locale.Connect;
try
Connection_Locale.StartTransaction;
Script_Local.SQL.Text := 'CREATE TABLE Ref_Compteurs (Reference string NOT NULL,Compteur integer,PRIMARY KEY (Reference));';
Script_Local.Execute;
Connection_Locale.Commit;
except
on e: Exception do
begin
if Connection_Locale.Connected then
Connection_Locale.Rollback;
raise;
end;
end;
finally
try
if Connection_Locale.Connected then
Connection_Locale.Close;
Script_Local.Free;
Connection_Locale.Free;
except
end;
end;
end;