Jump to content
Sign in to follow this  
kabiri

The problem of running the app on IOS

Recommended Posts

basically, FireDAC always needs a "TFDGUIxWaitCursor" to GUI dialogs, and a "PHYSxxxx" driver for your database used!

Quote

function TFDCustomManager.GetWaitCursor: TFDGUIxScreenCursor;  ... FireDAC.Comp.Client.pas, line 2654 used by all components like FDConnection, FDQuery, etc...

then, you need it!

the hierachy is:

  • FDManager; // always created by default if not used in your project...  all defined here will be inherited to next...
    • FDConnection; 
      • FDQuery/FDTable
        • etc....

 

my tip is: 

  • draw your DataModule by default on DesignTime... add your components: 1 FDxxxWaitCursor, 1 (or "n") FDPhysxxxxDriver, 1 FDConnection, "n" FDQueryxxxxx (so much than needs), DataSources, etc.. etc.. etc...
    • create your DataModule (automatically before main form (Project->Options) or on create form, or on Initialization section of your first unit on project, normally UnitMainForm)
    • code your FDConn initial params (if necessary, let for other place), now on "DataModuleCreate event" = OK!
    • if you need use your FDQuerys on any form after your app loaded, then, declare your initial "SQL statement ", for example, "select ...", ELSE, let it empty! when necessary, just put your SQL text to use!
  • as your DataModule is for use "global" now, then, in any unit you can use it!, ok?  clause "USES" myDataModuleMain;
  •  
Edited by programmerdelphi2k

Share this post


Link to post
29 minutes ago, kabiri said:

Yes , i khow. but when a put TFDConnection on the form delphi add "FireDAC.VCLUI.Wait" to DataModule unit!!!

I add FireDAC.FMXUI.Wait myself, but it didn't help. That's why I didn't put the component on the form.

I think that your "Configuration can be pointing to VCL project, not FMX"... look your Project Manager to see if you are using "FMX project" really!!!

image.thumb.png.86a9be46b2d59e218397feb8b198dec2.png

 

Edited by programmerdelphi2k
  • Thanks 1

Share this post


Link to post

Thanks @programmerdelphi2k

You are right.
I migrated from uniDac to FD and forgot to put the TFDGUIxWaitCursor component on the form and set the Provider property.

But putting it on the form didn't help the problem.

I noticed this happens on IOS when I call the GetDefaltCategory function on the untDataModule inside the DataModuleCreate function.

 

procedure TfrmDataModule.GetDefaltCategory;
var
  qry: TFDQuery;
begin
  qry := TFDQuery.Create(nil);
  qry.Connection := DBCon;
  qry.SQL.Clear;
  qry.SQL.Add('select * from ActiveBox');
  try
    qry.Open;
    if not qry.IsEmpty then
    begin
      DefaultCategory := qry.fieldByname('ActiveBox').asinteger;
      if DefaultCategory = 0 then
        DefaultCategory := 1;
    end
    else
      DefaultCategory := -1;
    qry.Close;
  except
  end;

//  if DefaultCategory = 0 then
//    DefaultCategory := 1;

  DefaultCategoryName := '';

  qry.Open;
  qry.SQL.Clear;
  qry.SQL.Add('select * from Category');
  qry.SQL.Add('where id=' + DefaultCategory.ToString);
  try
    qry.Open;
    if not qry.IsEmpty then
    begin
      DefaultCategoryName := qry.fieldByname('Name').AsString;
      FreeDownload := qry.fieldByname('FreeDownload').asinteger;
    end;
  except
  end;
  qry.Close;

  qry.Free;
end;

But when I call this function from somewhere else, there is no problem.

Share this post


Link to post

hi @kabiri

first, I would to say that your code is not good!!! Sorry, but really it's necessary review it (I think that all project).

 

Before developing a project, whether for the computer or for another activity, you should study what the tool offers you, and that it doesn't need to be reinvented.
For example, in the code above you want to know the name of the category based on an informed value. OK?
However, you are using a lot of code for a task that the database itself can provide for you without much effort.
Every SQL database, or not, has mechanisms that were developed to offer the minimum effort to the developer.
In the case above, you could simply create a "VIEW" query against the SQLite database to provide that information, as well as many others. This way, you wouldn't need to create so much code to get the same result and in a transparent way.

 

A word of advice: make your database work for you, not the other way around!

 

look my new sample for you using SQLite and creating a "VIEW" on database to easy access to informations in two tables (or more)

 

look this sample for you: see my SQLite "MySQLiteDBTest001.db" and code on project

https://mega.nz/file/r3gjmKwB#n5FILRJiqN-Jk3Yk7n97gDs2PlQi76Nvxgkd2HooLHE

NOTE: In no time do I need to create a query to check the value of a piece of information in the table!

Share this post


Link to post

It depends on whether you decide to use multiple queries or joins or views.

Since the ActiveLitnerBox table only contains one record, I decided not to use join tables.
The next reason was that in older versions the DefaultCategory could be zero (but I don't want to force the user to change it to 1), but in the newer version I decided that if this value was 0, I would consider a value of 1 for it.

This was not possible if I was using Join.

But it would have been better if I used if for the second query.

Writing code depends on how you look at it.

Edited by kabiri

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×