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
ZeosLib and Delphi XE7 - new database
-
- Platinum Boarder
- Posts: 1956
- Joined: 17.01.2011, 14:17
Re: ZeosLib and Delphi XE7 - new database
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:
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;
Re: ZeosLib and Delphi XE7 - new database
THanks for that. Sorry it took so long to get back. But we've been busy redeveloping the code.
Alan
Alan