1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
function AccessDatabaseCreator(_FileName : String) : String;
var catalog : OLEVariant;
begin
result := '';
try
catalog := CreateOleObject('ADOX.Catalog');
catalog.create ('Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_Filename+';');
catalog := NULL;
With Datamodule6 do
begin
ADOConnection2.ConnectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source='+_Filename+';Persist Security Info=False';
ADOConnection2.Connected:=true;
With CreationScript do
begin
CommandText:='CREATE TABLE TCollection (IDCollection INTEGER NOT NULL, Name VARCHAR(50) NOT NULL, PRIMARY KEY(IDCollection));';
Execute;
CommandText:='CREATE TABLE TCollectionKeywords (IDCollection INTEGER NOT NULL, IDKeywords INTEGER NOT NULL, PRIMARY KEY(IDCollection, IDKeywords));';
Execute;
CommandText:='CREATE TABLE TCollectionPhoto ( IDCollection INTEGER NOT NULL, IDPhoto INTEGER NOT NULL, PRIMARY KEY(IDCollection, IDPhoto), INDEX TCollectionTCollectionPhoto(IDCollection), INDEX TPhotoTCollectionPhoto(IDPhoto));';
Execute;
CommandText:='CREATE TABLE TFormat ( IDFormat INTEGER NOT NULL, Format VARCHAR(50) NOT NULL, PRIMARY KEY(IDFormat), INDEX FormatFormat(Format));';
Execute;
CommandText:='CREATE TABLE TGPSData ( IDGpsData INTEGER NOT NULL, Latitude VARCHAR(50) NOT NULL, Longitude VARCHAR(50) NOT NULL, Altitude VARCHAR(50) NOT NULL, TimeStamp DATETIME NOT NULL, GPSReferenceCoordonate INTEGER NOT NULL, PRIMARY KEY(IDGpsData));';
Execute;
CommandText:='CREATE TABLE TKeywords ( IDKeywords INTEGER NOT NULL, KeywordText VARCHAR(50) NOT NULL, PRIMARY KEY(IDKeywords));';
Execute;
CommandText:='CREATE TABLE TMetaData ( IDMetaData INTEGER NOT NULL, ImageWidth INTEGER NOT NULL, ImageHeight INTEGER NOT NULL, BitsPerComponent INTEGER NOT NULL, ImageResolution INTEGER NOT NULL, ShutterSpeed INTEGER NOT NULL,'+'ApertureValue INTEGER NOT NULL, ISOSetting INTEGER NOT NULL, MeteringMode INTEGER NOT NULL, FlashUsed INTEGER NOT NULL, ExposureBias INTEGER NOT NULL, PRIMARY KEY(IDMetaData));';
Execute;
CommandText:='CREATE TABLE TPhoto ( IDPhoto INTEGER NOT NULL, Thumbnail INTEGER NOT NULL, Filename VARCHAR(50) NOT NULL, PathToFile VARCHAR(50) NOT NULL, Format INTEGER NOT NULL, ImportDate DATETIME NOT NULL,'+'GPSData INTEGER NOT NULL, Photographer INTEGER NOT NULL, ExifData INTEGER NOT NULL, PRIMARY KEY(IDPhoto), INDEX FormatPhoto(Format), INDEX GPSDataPhoto(GPSData), INDEX TMetaDataTPhoto(ExifData), INDEX TPhotographerTPhoto(Photographer));';
Execute;
CommandText:='CREATE TABLE TPhotographer ( IDPhotographer INTEGER NOT NULL, Firstname VARCHAR(50) NOT NULL, Lastname VARCHAR(50) NOT NULL, Nickname VARCHAR(50) NOT NULL, Email VARCHAR(50) NOT NULL, PRIMARY KEY(IDPhotographer));';
Execute;
CommandText:='CREATE TABLE TPhotoKeyword ( IDPhoto INTEGER NOT NULL, IDKeywords INTEGER NOT NULL, PRIMARY KEY(IDPhoto, IDKeywords), INDEX TKeywordsTPhotoKeyword(IDKeywords), INDEX TPhotoTPhotoKeyword(IDPhoto));';
Execute;
end; // With
ADOConnection2.Connected:=false;
end; // with
except
on e : Exception do result := e.message;
end;
end; |
Partager