- Create FDGUIxWaitCursor1 and change ScreenCursor
- Add FireDAC.Dapt into Uses list
How to Start Conection
FDConnection1.ResourceOptions.MacroCreate:=False; // '&', '!' characters fails to execute correctly
FDConnection1.ResourceOptions.MacroExpand:=False; // '&', '!' characters fails to execute correctly
FDConnection1.Params.Clear;
FDConnection1.Params.Add('DriverID=SQLite');
FDConnection1.Params.Add('Database='+mydir+'database.db');
try
FDConnection1.Connected := true;
except
on E: EDatabaseError do
ShowMessage('Exception raised with message' + E.Message);
end;
CRUD Operations
function Escape(Str: string):string;
begin
Result:=QuotedStr(Str);
end;
var
results: TDataSet;
query: String;
myid: string;
mystart: int64;
begin
query := 'select ID, START from FILES where FILENAME='+ESCAPE(filename)+' LIMIT 1;';
try
FDConnection1.ExecSQL(query, nil, results);
except
on E: Exception do
showmessage('Exception raised with message: ' + E.Message);
end;
if not results.IsEmpty then
begin
results.First;
while not results.Eof do
begin
myid:=results.FieldByName('ID').AsString;
mystart:=results.FieldByName('START ').AsInteger;
//mystart:=results.Fields[1].AsInteger;
results.Next;
end;
end;
end;
var
query: String;
begin
query := 'insert into FILES (FILENAME,START) values ('+Escape(FileName)+','+Escape(mystart.ToString)+');';
try
FDConnection1.ExecSQL(query);
except
on E: Exception do
showmessage('Exception raised with message: ' + E.Message);
end;
query := 'update FILES SET FINISH='+Escape(myfinish.ToString)+' where ID='+Escape(myid)+';';
try
FDConnection1.ExecSQL(query);
except
on E: Exception do
showmessage('Exception raised with message: ' + E.Message);
end;
end;
If you don’t know return query results set or not, there is workaround – TFDquery.OpenOrExecute. But internal exception when query does not return result set.