Page 1 of 1

Creating a database with UniDAC

Posted: Wed 25 Nov 2009 09:47
by upscene
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

Posted: Wed 25 Nov 2009 09:57
by Plash
To create a Firebird/InterBase database, use the TUniScript component with CREATE DATABASE statement in it. Set the Preconnect property of TUniScript to False.

Posted: Wed 25 Nov 2009 10:03
by upscene
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?

Posted: Thu 26 Nov 2009 09:04
by Plash
Execute the DROP DATABASE statement in TUniScript.

Example Please

Posted: Mon 14 Dec 2009 18:55
by Farhan
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.

Posted: Tue 15 Dec 2009 10:06
by Plash
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;

Posted: Fri 30 Jul 2010 03:13
by 99Percent
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.