App hangs when giving create in Datamodule

Asked

Viewed 428 times

0

I am creating an Android application in delphiXE7 and everything works until I will create dynamically the datamodule. Then it hangs and does not come back.

procedure TForm1.Btn1Click(Sender: TObject);
var M:TModalResult;
begin
Application.CreateForm(TDataModule1, DataModule1);
end;

I had to make this dynamic create because before, when it automatically created the application only got a black screen and did not start.

Remembering that you don’t even execute this code in the Tfdconnection Beforeconnection;

{$IF DEFINED (IOS) || (ANDROID)}
DataModule1.Conn1.Params.Values['DriverID'] := 'SQLite';
try
DataModule2.Conn1.Params.Values['Database']:= TPath.Combine(TPath.GetDocumentsPath, 'Banco002.SQLite');
DataModule2.Conn1.Connected := True;
      except on E: Exception do
      begin
        raise Exception.Create('Erro de conexão com o banco de dados!');
      end;
{$ENDIF}

Has anyone ever had a problem? Usage Xe7, sqlite, Android 4.2 Samsung DUOS Smartphone and SDK updated.

  • 1

    Pq you do not put the Datamodule in the project’s autocreate and connect it to the database via the Datamodule Create. One question, this extension of the right Sqllite?... wouldn’t it be Banco002.db

  • I saved with the Sqllite extension to differ from old verses I was using.

1 answer

1

I was able to identify the problem. While testing the APP in designtime, I forgot an open table and, as the mobile path of the bank was different, so the application crashed, because I was looking for the database of the method

{$IF DEFINED (IOS) || (ANDROID)}
DataModule1.Conn1.Params.Values['DriverID'] := 'SQLite';
try
DataModule2.Conn1.Params.Values['Database']:= TPath.Combine(TPath.GetDocumentsPath, 'Banco002.SQLite');
DataModule2.Conn1.Connected := True;
      except on E: Exception do
      begin
        raise Exception.Create('Erro de conexão com o banco de dados!');
      end;
{$ENDIF}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.