Topic: Updating DBFile

Hi.
in my project there is a DBFile which is set on LinkFile and has a CopyTo command.
is there any way that the DBFile save each record in a separate folder?
What I mean is that when I save a the first record, the DBFile save the related file in the Folder "Record1"
and  when I save the second record, the DBFile save the related file in the Folder "Record2" and so on
thanks

Re: Updating DBFile

Hello,


I made an example for you:

Post's attachments

Attachment icon DBFile each record in separate folder 1.45.zip 6.2 kb, 450 downloads since 2016-02-10 

Dmitry.

Re: Updating DBFile

thank you so much
can this script be used for 3 DBFiles?
I have decided to use 3 DBfiles in my project with your awesome script.
and also is there a way that instead of the name "Record1" each file is saved in a folder with the name "First name + Last name" ?
thanks

4 (edited by identity 2016-02-12 20:08:00)

Re: Updating DBFile

Hi
I have solved the 3 DBFile problem myself.
but I don't know the script for the other problem. please help me to correct the attached project
what I need to do is that the address in which these 3 DBfiles are saved, should be like:
DBFile 1:  files\first name+last name\a
DBFile 2:  files\first name+last name\b
DBFile 3:  files\first name+last name\c
as you can see all of them are save in one directory but separate folders . for example:
DBfile1 of the first record goes to "files\john+smith\a"
DBfile2 of the first record goes to "files\john+smith\b"
DBfile3 of the first record goes to "files\john+smith\c"
thanks

Post's attachments

Attachment icon DBFile each record in separate folder 1.45.rar 294.58 kb, 459 downloads since 2016-02-12 

Re: Updating DBFile

identity
Hello,


Try this script:

procedure frmEmployee_Button2_OnClick (Sender: string; var Cancel: boolean);
var
   sID: string;

begin
     if frmEmployee.Button2.dbGeneralTableid = -1 then sID := SQLExecute('SELECT IFNULL(MAX(id), 0)+1 FROM employees')
     else sID := IntToStr(frmEmployee.Button2.dbGeneralTableid);

     frmEmployee.DBFile1.dbCopyTo := 'files\Record'+sID+'\a';
     frmEmployee.DBFile2.dbCopyTo := 'files\Record'+sID+'\b';  
     frmEmployee.DBFile3.dbCopyTo := 'files\Record'+sID+'\c';  
end;
Dmitry.

6 (edited by identity 2016-02-13 09:19:28)

Re: Updating DBFile

Thank you
your script works fine but the DBFiles still saves the file in a folder named Record1 and Record2 and so on.
is it possible at all that instead of saving files base on records, DBFiles save the files in a folder with the names based on the textboxes "edFistName + edLastName" ???
for example the DBFile1 of the first record are saved in this directory: "files\john+smith\a"

Re: Updating DBFile

Sorry, forgot about Last name and First name

procedure frmEmployee_Button2_OnClick (Sender: string; var Cancel: boolean);
begin
     frmEmployee.DBFile1.dbCopyTo := 'files\'+frmEmployee.edLastName.Text+' '+frmEmployee.edFistName.Text+'\a\';
     frmEmployee.DBFile2.dbCopyTo := 'files\'+frmEmployee.edLastName.Text+' '+frmEmployee.edFistName.Text+'\b\';
     frmEmployee.DBFile3.dbCopyTo := 'files\'+frmEmployee.edLastName.Text+' '+frmEmployee.edFistName.Text+'\c\';
end;
Dmitry.