Create Database + Table From Scratch (Programatically)
Posted: 30.03.2010, 05:22
I'm making a very simple "portable" (and open source), application.
I have not programed in Delphi DB in the last 8 years, so i don't remember much.
The good thing is that now there is "the internets", but i can not find some answers.
I want my application to start, and if it does not finds a database, create it and create the tables.
So far, i have:
But, how do i create a simple table, that has 1 text field, 1 data field, and one memo field, indexed by the 1st text field?
Thanks.
I have not programed in Delphi DB in the last 8 years, so i don't remember much.
The good thing is that now there is "the internets", but i can not find some answers.
I want my application to start, and if it does not finds a database, create it and create the tables.
So far, i have:
Code: Select all
ZConnection.Disconnect;
ZConnection.Protocol := 'sqlite-3';
ZConnection.Database := ExtractFilePath(Application.ExeName) + '/database.SQLite3';
if not FileExists(ZConnection.database) then
begin
ZConnection.Properties.Add('createnewdatabase=create database '''+ZConnection.Database+''' user ''sysdba'' password ''masterkey'' page_size 4096 default character set iso8859_2;');
try
ZConnection.Connect;
except
ShowMessage('no pude conectar (y no existia!)');
application.Terminate;
end;
end else
begin
try
ZConnection.connect;
except
ShowMessage('no pude conectar (y SI existia!)');
application.Terminate;
end;
end;
Thanks.