How to create a DB
Moderators: gto, cipto_kh, EgonHugeist
How to create a DB
Hi,
I'm newer in Zeos and Firebird, then, I think, my question will be so easy for you but seems so difficult for me. Ok.
How Can I create a new DB with FB server on disk ??
Wich Zeos component I use ??
I tried creating it this evening. I used TZSQLProcessor component but it has to be connected to TZConnection wich, itself, must be connected to physical DB.
My goal is to create this DB ! This is my problem !
Thanks for your help.
Regards.
I'm newer in Zeos and Firebird, then, I think, my question will be so easy for you but seems so difficult for me. Ok.
How Can I create a new DB with FB server on disk ??
Wich Zeos component I use ??
I tried creating it this evening. I used TZSQLProcessor component but it has to be connected to TZConnection wich, itself, must be connected to physical DB.
My goal is to create this DB ! This is my problem !
Thanks for your help.
Regards.
firebirdd-2.1
RAD 2009
svn://zeos.firmos.at/zeos/trunk from 11.2.2009
ZConnection1.Database := MyDir+'\COL.FDB';
- not exists
ZConnection1.Connect;
// ZConnection1.Connected return true ??????
ZConnection1.DisConnect; // or not
ZSQLProcessor1.Script.Text := 'CREATE DATABASE '+
QuotedStr(ZConnection1.Database)+ ' USER ' + QuotedStr(ZConnection1.User) +' PASSWORD ' + QuotedStr(ZConnection1.Password);
ZSQLProcessor1.Execute;
ERROR> Statement is not allowed
?
Thanks
RAD 2009
svn://zeos.firmos.at/zeos/trunk from 11.2.2009
ZConnection1.Database := MyDir+'\COL.FDB';
- not exists
ZConnection1.Connect;
// ZConnection1.Connected return true ??????
ZConnection1.DisConnect; // or not
ZSQLProcessor1.Script.Text := 'CREATE DATABASE '+
QuotedStr(ZConnection1.Database)+ ' USER ' + QuotedStr(ZConnection1.User) +' PASSWORD ' + QuotedStr(ZConnection1.Password);
ZSQLProcessor1.Execute;
ERROR> Statement is not allowed
?
Thanks
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Can you add a TZSQLMonitor to your application to log the generated SQL? (Using dummy user/password combinations, of course)
When that doesn't help us, we you might try to zip all needed files (your project dir without dcu's and exe file but including the embedded server stuff) and send it to our project mail adres ( reverse('moc.liamg@bilsoez') )
So we can try it ourselves.
Mark
When that doesn't help us, we you might try to zip all needed files (your project dir without dcu's and exe file but including the embedded server stuff) and send it to our project mail adres ( reverse('moc.liamg@bilsoez') )
So we can try it ourselves.
Mark
See: http://www.firebirdfaq.org/faq67/
isc_create_database function isn't declared in ZPlain(Interbase|Firebird)Driver.pas, so currently is not possible to create firebird db programaticaly.
isc_create_database function isn't declared in ZPlain(Interbase|Firebird)Driver.pas, so currently is not possible to create firebird db programaticaly.
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
trupka,
This functionality actually IS provided in zeoslib.
To use it, you must set a connection.properties line:
(From doc\pdf\parameters.pdf in the zeoslib package)
This does really work. If you provide me with an email address using a private message I could send you a working example.
SlavoF, gto,
The referenced article was for postgres. There creating a database after connecting is possible using SQL. For interbase the database will be created before the actual connect.
Mark
This functionality actually IS provided in zeoslib.
To use it, you must set a connection.properties line:
Code: Select all
createNewDatabase=<sql command database creation>
This does really work. If you provide me with an email address using a private message I could send you a working example.
SlavoF, gto,
The referenced article was for postgres. There creating a database after connecting is possible using SQL. For interbase the database will be created before the actual connect.
Mark
Thanks for info, Mark.
Things are much clearer after reading docs - "createNewDatabase" is feature I wasn't aware of
For those who want to create Firebird database programaticaly, here is little code sample that works with embedded firebird:
Things are much clearer after reading docs - "createNewDatabase" is feature I wasn't aware of
For those who want to create Firebird database programaticaly, here is little code sample that works with embedded firebird:
Code: Select all
with ZConnection1 do
begin
if not Connected
then begin
// if database doesn't exists
if not FileExists(Database)
then
// try to create it on connection
Properties.Add(
format('createNewDatabase=CREATE DATABASE %s USER %s PASSWORD %s',
[QuotedStr(Database), QuotedStr(User), QuotedStr(Password)])
);
Connect;
end;
end;
:-(
I don´t know
error must be otherwhere
connected = true , but database not exists
http://www.davidplus.sk/test/firebird.zip
I don´t know
error must be otherwhere
connected = true , but database not exists
http://www.davidplus.sk/test/firebird.zip
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Sorry, no FB server installed here. So I can't test this myself. Do you get an error at connection when pressing button 3? Which one?
From the log file in the zip file I make the conclusion this database has been created. The connection was successful and a transaction has started.
I think the main question is where the firebird server has stored the file exactly. I don't know how the server decides where to put his databases.
Some idea's I have as a FB amateur:
- Does FB server puts the files somewhere relative to a datadir?
- May the 'Space' in the path cause trouble putting the file somewhere in a strange location?
Mark
From the log file in the zip file I make the conclusion this database has been created. The connection was successful and a transaction has started.
I think the main question is where the firebird server has stored the file exactly. I don't know how the server decides where to put his databases.
Code: Select all
2009-02-13 11:20:04 cat: Connect, proto: firebird-2.1, msg: CREATE DATABASE "CREATE DATABASE 'D:\CodeGear\RAD Studio\6.0\Projects\Firebird\DB\COL.FDB' USER 'SYSDBA' PASSWORD 'masterkey'" AS USER "SYSDBA"
2009-02-13 11:20:04 cat: Connect, proto: firebird-2.1, msg: CONNECT TO "D:\CodeGear\RAD Studio\6.0\Projects\Firebird\DB\COL.FDB" AS USER "SYSDBA"
2009-02-13 11:20:04 cat: Transaction, proto: firebird-2.1, msg: TRANSACTION STARTED.
- Does FB server puts the files somewhere relative to a datadir?
- May the 'Space' in the path cause trouble putting the file somewhere in a strange location?
Mark