ZeosLib and Delphi XE7 - new database

The official tester's forum for ZeosLib 7.1. Ask for help, post proposals or solutions.
Alancj
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.01.2017, 21:51

ZeosLib and Delphi XE7 - new database

Postby Alancj » 11.01.2017, 02:20

I'm attempting to set up an app that starts up when the user first activates the software. The first task is to create the system's database. Bluntly - I'm getting no where. The database is MySQL5.5

As far as I can figure I'm doing what needs to be done. But nothing happens.

I'm using a ZConnection component.

Autocommit is off. The hostname is LocalHost - because the first installation must be activated on the server PC. The user is "root" and their password is also "root". The MySQL libraries are being found no trouble.

The code is as follows:

with ZConnection1 do
begin
try
Connect;
Properties.Add('CreateNewDatabase=CREATE DATABASE' + QuotedStr('test1') + 'IF NOT EXISTS' + 'DEFAULT CHARACTER SET UTF8');
Commit;

except
Properties.Clear;
Connect;
end;
end;

No error is triggered. But no database is created either.

Any assistance would be appreciated.

Thanks

Alan

marsupilami
Gold Boarder
Gold Boarder
Posts: 606
Joined: 17.01.2011, 14:17

Re: ZeosLib and Delphi XE7 - new database

Postby marsupilami » 11.01.2017, 16:15

Hello Alan,

the CreateNewDatabase parameter only exists for the Interbase and Firebird drivers. The MySQL driver ignores this parameter. Why don't you connect to the mysql database, create your database and then disconnect and reconnect to your new database?
Something like this is on my mind:

Code: Select all

with ZConnection1 do
begin
  try
    Database := 'mysql';
    Connect;
    ExecuteDirect('CREATE DATABASE ' + QuotedStr('test1') + ' IF NOT EXISTS ' + ' DEFAULT CHARACTER SET UTF8';
    Commit;
    Disconnect;
   
    Database := 'test1';
    Connect;
  except
    if Active then Rollback;
    Disconnect;
    Raise;
  end;
end;

Alancj
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 10.01.2017, 21:51

Re: ZeosLib and Delphi XE7 - new database

Postby Alancj » 24.11.2017, 02:32

THanks for that. Sorry it took so long to get back. But we've been busy redeveloping the code.

Alan


Return to “ZeosLib 7.1 stable Forum”

Who is online

Users browsing this forum: No registered users and 1 guest