Database creation issues

In this forum we will discuss things relating the ZEOSLib 6.6.x stable versions

Moderators: gto, EgonHugeist

Post Reply
User avatar
Pitfiend
Senior Boarder
Senior Boarder
Posts: 68
Joined: 12.12.2009, 07:27

Database creation issues

Post by Pitfiend »

I was using this amazing component library to build many of my recents projects. In earlier development stages, I was wondering if it is possible to create databases directly using the Zeos components to enable my applications to be distribute in easier ways for my users.

I was looking into the forums but nothing seems to work. Can anyone explain us how to create databases using the various Zeos drivers?
cariad
Junior Boarder
Junior Boarder
Posts: 36
Joined: 20.10.2005, 14:07

Post by cariad »

Hello,

Here's a snippet to create a Firebird embedded database. I don't have the code for the others backends (Connection is a TZConnection object).

Code: Select all

    Connection.Database := 'C:\file.fdb';
    Connection.User := 'Username';
    Connection.Password := 'Password';
    Connection.Protocol := 'firebird-2.0';
    Connection.Properties.Clear;
    Connection.Properties.Text :=  'CreateNewDatabase=CREATE DATABASE ' +
      QuotedStr ('C:\file.fdb') + ' USER ' +
      QuotedStr ('Username') + ' PASSWORD ' + QuotedStr ('Password') +
      ' PAGE_SIZE=4096 DEFAULT CHARACTER SET UTF8';
    Connection.Connect;
    Connection.Disconnect;
    Connection.Properties.Clear;
Hope it helps.
User avatar
Pitfiend
Senior Boarder
Senior Boarder
Posts: 68
Joined: 12.12.2009, 07:27

Post by Pitfiend »

Nice, thanks. Anyone else can contribute with the others? What I'm looking for, is the creation of MS Access using ADO driver.

If anyone want to create a SQLite database, here's how (again Connection is a TZConnection object):

Code: Select all

Connection.Protocol:='sqlite-3';
Connection.Database:='C:\Database.sqlite';
Connection.Connect;
You must provide the sqlite dll in the same directory than your application, in the windows system directory or the search path.

Then you can create tables using standar SQL CREATE TABLE.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

For mysql :
just connect to the server (without specifying a database or using the system database 'mysql'). Then

Code: Select all

ZConnection.ExecuteDirect('create database <dbname>');
Sorry, no ADO experience nor knowledge.

Mark
Image
User avatar
Pitfiend
Senior Boarder
Senior Boarder
Posts: 68
Joined: 12.12.2009, 07:27

Post by Pitfiend »

Hey guys... it will be nice if someone else contribute with his knowledge. Being part of a community means to share with it.
Post Reply