Error on connect to the SQLite database with Firemonkey IOS app

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Error on connect to the SQLite database with Firemonkey IOS app

Post by josecarlos » Sun 08 Jul 2012 22:34

I am still trying to get the UniDac Sqlite/IOS working.

This error is happening on UniConnection.Connect; , and I got an EXE_BAD_ACCESS on the Xcode side.

On the code below I am testing two ways to use sqlite and I have two buttons and a memo,

The button btnSQLite3db I put the Hacker's corner sample and it is working.

The button btnUniDac, I am using dimitry's sample and just change the database file name to get the documents folder, when I click this button I got EXE_BAD_ACCESS.

How to fix this?

Is there an IOS sample ?

I am using the latest Unidac source with XE2 Update 4 hot fix 1

Code: Select all

unit Unit2;

{$IFDEF FPC}
{$mode delphi}
{$modeswitch objectivec1}
{$ENDIF}

interface

uses
  SysUtils, Types, UITypes, Classes, Variants, FMX_Types, FMX_Controls, FMX_Forms,
  FMX_Dialogs, DB, DBAccess, UniProvider, SQLiteUniProvider, Uni, FMX_Layouts,
  FMX_Memo
  {$IFDEF FPC}
, iPhoneAll, SQLite3db, SQLite
{$ENDIF};

type
  TForm2 = class(TForm)
    btnUnidac: TButton;
    btnSQLite3db: TButton;
    Memo1: TMemo;
    procedure btnUnidacClick(Sender: TObject);
    procedure btnSQLite3dbClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form2: TForm2;

implementation

{$R *.lfm}


{$IFDEF FPC}
function MyDirectory : NSString;
var
  paths : NSArray;
  fileName : NSString;
begin
  paths := NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, True);
  fileName := paths.objectAtIndex(0);
  Result := fileName;
end;
{$ENDIF}

procedure TForm2.btnUnidacClick(Sender: TObject);
var
  UniConnection: TUniConnection;
  UniQuery: TUniQuery;
begin
  UniConnection := TUniConnection.Create(nil);
  UniQuery := TUniQuery.Create(nil);
  try
    UniConnection.ProviderName := 'SQLITE';
    UniConnection.Database     :=  String(MyDirectory.UTF8String)+'/UniDac.sqlite';
    UniConnection.Connect;
    UniConnection.ExecSQL('CREATE TABLE T_TEST (ID INTEGER, NAME VARCHAR(50))',[]);
    UniConnection.ExecSQL('INSERT INTO T_TEST VALUES(1, ''Test Name'')',[]);

    UniQuery.Connection := UniConnection;
    UniQuery.SQL.Text := 'SELECT * FROM T_TEST';
    UniQuery.Open;

    ShowMessage(UniQuery.FieldByName('ID').AsString + ' - ' + UniQuery.FieldByName('NAME').AsString);

    UniQuery.Append;
    UniQuery.FieldByName('ID').AsInteger := 2;
    UniQuery.FieldByName('NAME').AsString := 'New Name';
    UniQuery.Post;

    ShowMessage(UniQuery.FieldByName('ID').AsString + ' - ' + UniQuery.FieldByName('NAME').AsString);

    UniQuery.Close;
  finally
    UniQuery.Free;
    UniConnection.Free;
  end;
end;

procedure TForm2.btnSQLite3dbClick(Sender: TObject);
var
  FileName, SQL : String;
  DB : TSQLite;
  SL : Classes.TStringList;

begin
  FileName := String(MyDirectory.UTF8String)+'/MyDB.sqlite';

  DB := TSQLite.Create(FileName);

  // Create the table
  SQL := 'create table Customers (Id integer not null, LastName char(25), FirstName char(25))';
  DB.Query(SQL,nil);

  // Insert a couple of records
  SQL := 'insert into Customers values(1, "Ohlsson", "Anders")';
  DB.Query(SQL,nil);
  SQL := 'insert into Customers values(2, "Intersimone", "David")';
  DB.Query(SQL,nil);

  // Get the records back and list them in the memo
  SL := Classes.TStringList.Create;
  SQL := 'select * from Customers';
  if DB.Query(SQL,SL) then
    Memo1.Text := SL.Text;
  SL.Free;

  DB.Free;

end;


end.


AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by AlexP » Mon 09 Jul 2012 14:56

hello,

The sample you have provided works with no errors: a DB can be created and opened, if it exists already. The only place, where an error can occur, is the create table operator, since when a table with such name exists, an error will occur, therefore it is better to add a check IF NOT EXISTS.
P.S. Please specify your xCode and iOS versions

josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by josecarlos » Mon 09 Jul 2012 19:58

I got this error on Xcode 4.2 ( IOS 5.0.1 ) and Xcode 4.3.2 ( IOS 5.1 ).

The error happens on the db.connect, and I test it on the iPhone simulator and in a real iPad.

My code worked in your tests, I am reinstalling and checking everything, but on my mac/xcode the line db.connect raises an EXC_BAD_ACCESS and stops on the procedure destroyPixelShader of the unit FMX_Context_GLES.pas.

If you have some idea I will appreciate.

Thanks.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by AlexP » Tue 10 Jul 2012 08:50

hello,

We checked our components on xCode 3.2.6 (iOS 4.3), maybe the problems are really due to the new versions of the software. We will try to check our products on these versions in the nearest future.
P.S. Please, also make sure that you have an installed FireMonkey-iOS.dmg package from the latest version of RadStudio

josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by josecarlos » Tue 10 Jul 2012 10:34

I am using the latest Firemonkey-IOS package from the update 4 Hotfix 1.

So, I am waiting for this fix.

Thanks,

Jose Carlos.

josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by josecarlos » Sat 14 Jul 2012 15:53

AlexP wrote:hello,

We checked our components on xCode 3.2.6 (iOS 4.3), maybe the problems are really due to the new versions of the software. We will try to check our products on these versions in the nearest future.
P.S. Please, also make sure that you have an installed FireMonkey-iOS.dmg package from the latest version of RadStudio
How long will take to get the UniDac/Sqlite working with IOS 5 ? I need this to start a new project and bought unidac only for this project.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by AlexP » Tue 17 Jul 2012 10:30

hello,

The xCode 4.2 and iOS 5.0 support is planned in two weeks. Higher versions of xCode and iOS are presently not supported by RadStudio

josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by josecarlos » Tue 17 Jul 2012 19:53

I can't use xCode 3.2.6, this is really bad.

My OSX is LION 10.7.2 and I only have xCode 4 to download, the earlier version is not supported on Lion.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by AlexP » Tue 31 Jul 2012 08:26

Hello,

We have fixed the problems when connecting to SQLite in iOS 5.0. Now, for developing applications on iOS 5.0, you can use XCode 4.2, the later versions of iOS and Xcode are not supported yet by Embarcadero.
The new UniDAC version 8.3.8 including this fix is already available at our site

josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by josecarlos » Tue 31 Jul 2012 19:35

I downloaded yesterday the latest Unidac version, and it is working, Xcode 4.3.2 and IOS 5.1.

Thanks,

Jose Carlos.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by AlexP » Wed 01 Aug 2012 12:18

hello,

There is the following information at the Embarcadero website ( http://docwiki.embarcadero.com/RADStudi ... up_for_iOS):
Xcode version 3.2.5 to 4.2 verified working.
iOS SDK version 4.2.x, 4.3.x, or 5.0 verified working.
Therefore we checked the workability of our products exactly on these versions, and we cannot guarantee the stable work on later versions of XCode and iOS

josecarlos
Posts: 36
Joined: Sat 30 Jul 2011 18:35
Location: Brazil
Contact:

Re: Error on connect to the SQLite database with Firemonkey IOS app

Post by josecarlos » Thu 02 Aug 2012 14:04

yep, I know that, but so far it is working.

If I get any issue, I will downgrade to IOS 5.0

Thanks.

Post Reply