dosya arama sonucunda bulunan dosya yollarını eklemek istiyorum fakat sadece tek bir tane ekleme yapıyor.
Kod: Tümünü seç
procedure TMyThread.FileSearchEx(const PathName: string; const Extensions: string);
const
FileMask = '*.*';
var
Rec: TSearchRec;
slDBpath: string;
sldb: TSQLiteDatabase;
sltb: TSQLIteTable;
sSQL: String;
i : integer;
ekle,sira,deger : string;
Path,yol: string;
position: integer;
begin
Path := IncludeTrailingPathDelimiter(PathName);
sira:= '2';
deger := '15';
if FindFirst(Path + FileMask, faAnyFile - faDirectory, Rec) = 0 then
begin
try
repeat
if PosEx(ExtractFileExt(Rec.Name), Extensions) > 0 then
begin
FNewLine := Path + Rec.Name;
Synchronize(UpdateList);
slDBPath := ExtractFilepath(application.exename) + 'test.db'; // sql lite database başlangıcı
sldb := TSQLiteDatabase.Create(slDBPath);
try
if sldb.TableExists('testTable') then begin
sSQL := 'DROP TABLE testtable';
sldb.execsql(sSQL);
end;
sSQL := 'CREATE TABLE testtable ([ID] INTEGER PRIMARY KEY,[OtherID] INTEGER NULL,';
sSQL := sSQL + '[Name] VARCHAR (255),[Number] FLOAT, [notes] BLOB, [picture] BLOB COLLATE NOCASE);';
sldb.execsql(sSQL);
sldb.execsql('CREATE INDEX TestTableName ON [testtable]([Name]);');
sldb.BeginTransaction;
begin
sSQL := 'INSERT INTO testtable(Name,OtherID,Number,Notes) VALUES ("'+ FNewLine + '","'+ sira + '","'+ deger + '","Eklenen notlar");'; // ekleme yap
sldb.ExecSQL(sSQL);
end;
sldb.Commit;
sltb := slDb.GetTable('SELECT * FROM testtable');
finally
sltb.Free;
end;
end;
until (Terminated) or (FindNext(Rec) <> 0);
finally
FindClose(Rec);
end;
end;
if FindFirst(Path + FileMask, faDirectory, Rec) = 0 then
begin
try
repeat
if (Rec.Name <> '.') and (Rec.Name <> '..') then
FileSearchEx(Path + Rec.Name, Extensions);
until (Terminated) or (FindNext(Rec) <> 0);
finally
FindClose(Rec);
end;
end;
end;