Creating a database with UniDAC

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
upscene
Posts: 306
Joined: Thu 19 Oct 2006 08:13

Creating a database with UniDAC

Post by upscene » Wed 25 Nov 2009 09:47

Hi,

can you give me an example on how to create a database with UniDAC?

I have no problem using TGDSConnection for that, this is entirely possible in my application.

Thanks,

Martijn Tonies
Upscene Productions

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 25 Nov 2009 09:57

To create a Firebird/InterBase database, use the TUniScript component with CREATE DATABASE statement in it. Set the Preconnect property of TUniScript to False.

upscene
Posts: 306
Joined: Thu 19 Oct 2006 08:13

Post by upscene » Wed 25 Nov 2009 10:03

Plash wrote:To create a Firebird/InterBase database, use the TUniScript component with CREATE DATABASE statement in it. Set the Preconnect property of TUniScript to False.
Sounds like an easy to use work around :)

Any example for Drop Database as well?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 26 Nov 2009 09:04

Execute the DROP DATABASE statement in TUniScript.

Farhan
Posts: 1
Joined: Mon 14 Dec 2009 18:50

Example Please

Post by Farhan » Mon 14 Dec 2009 18:55

Can you give us an example that how can we create database using .sql text files?please share a demo using uniscript and unidac. thanks.

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 15 Dec 2009 10:06

Use the SQL text like the following:

Code: Select all

CREATE DATABASE 'C:\db.gdb'
USER 'sysdba' PASSWORD 'masterkey'
PAGE_SIZE 4096
Use the Pascal code like the following:
UniScript1.SQL.LoadFromFile('sql.txt');
UniScript1.NoPreconnect := True;
UniScript1.Execute;

99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

Post by 99Percent » Fri 30 Jul 2010 03:13

Correct me if I am wrong but this doesn't work in PostgreSQL if you don't have a database already created because the Connection property requires a database, even if Nopreconnect=True;

edited to add: I discovered that the default installation of PostgreSQL (at least in 8.4) creates a default database "postgres". My mistake was deleting this default database. I suggest you don't delete it if you plan to programmatically create databases, until atleast one database is created because its a real hassle to create new databases without an initial database since the user login generally requires a database to log on to.

Post Reply