数据库相关
function TSJGY.OpenSQL(SQL: string; AFDQuery: TFDQuery): Boolean;
begin
result := False;
try
AFDQuery.Connection := MainDM.FDConnection1;
AFDQuery.FetchOptions.Mode := TFDFetchMode.fmall;
AFDQuery.SQL.text := SQL;
AFDQuery.Open;
result := true;
except
result := False;
end;
end;
// 执行一个SQL语句
function TSJGY.ExecSQL(SQL: string): Boolean;
begin
result := False;
try
MainDM.FDQuery_temp.SQL.text := SQL;
MainDM.FDQuery_temp.ExecSQL;
result := true;
except
result := False;
end;
end;
procedure TMainDM.FDConnection1BeforeConnect(Sender: TObject);
begin
// 告诉手机程序,数据库的真实位置,安卓和苹果不一样
// was: GetHomePath + PathDelim +
// 'Documents' + PathDelim + 'tasks.s3db';
// {$IFDEF IOS}
// FDConnection1.Params.Values['Database'] := GetHomePath + PathDelim +
// 'Documents' + PathDelim + 'data.s3db';
// {$ENDIF}
// {$IFDEF android}
// FDConnection1.Params.Values['Database'] := TPath.GetDocumentsPath + PathDelim
// + 'data.s3db';
// {$ENDIF}
// {$IFDEF MSWINDOWS}
// FDConnection1.Params.Values['Database'] := TPath.GetDocumentsPath + 'data.s3db';
// {$ENDIF}
try
{$IF DEFINED(IOS) or DEFINED(ANDROID)}
FDConnection1.Params.Values['Database'] := TPath.GetDocumentsPath + PathDelim + 'MMS.s3db';
{$ENDIF}
except
end;
// iOS的Remote path 设置为:StartUp\Documents\
// Android的Remote path 设置为:Assets\internal\
end;