some problem was occured in closing dataset

hi experts,

I do some work in afterinsert event of  a table( my work is copying a file to a special location) .
But if user close the dataset(closing the data entry form without any change) this file(copyied file)is unused.
How can prevent of this work(with informing of unchanging in dataset)?

thanks in advance
m.reza

ImbeginnerAsked:
Who is Participating?
 
kretzschmarConnect With a Mentor Commented:
>1-I want to know you earn money for your high experts points.

no, i get no money and no naturals :-))

>2-I dont understand what is the oncancel event

sorry, my mistake,
i meant the beforecancel-event -> sorry

>In my mind I can add this deletion  ON  E: EDATABASEERROR

there is better place -> onposterror

but i would prefer the beforecancel event,
because after an error the dataset will stay
in editmode until you cancel it or you get it
properly posted

but this depends on your app and
on the possibilities if and how a
user can handle these errors within
your app byself.

if the user never can handle db-errors, then
use the onposterror-event for deletion.

meikl ;-)
0
 
kretzschmarCommented:
move your afterinsert-event-code into
the beforepost-event like

...
  If Dateset.State = dsInsert then
  begin
    //here code what has been in the afterinsert-event
  end;
...

meikl ;-)
0
 
ImbeginnerAuthor Commented:
One problem
When a problem in data entry was occurred the last problem remained.
The data was send to database and database realize that example primary key has null value or dublicated value .
In this case the file was copied but unuseful.
How can solve this problem ?

thanks
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
ImbeginnerAuthor Commented:
any feed back from you kretzschmar?
i increased my points to 50.

thank
0
 
kretzschmarCommented:
sorry for delay, points doesn't matter

hmm,
thats bad,
in this case a movement of your code isn't
the solution.

another try would be to supply the onCancel-event,
for deletion the just copied file

would this work for you?

meikl ;-)
0
 
ImbeginnerAuthor Commented:
I have two questions:

1-I want to know you earn money for your high experts points.

2-I don’t understand what is the oncancel –event.
I see aftercancel for adotable1 but ….
I say my idea for this problem with help of your first comment :

In my mind I can add this deletion  ON  E: EDATABASEERROR , for it I should define tempfile1(location of file) as global  variable.
But I don’t know  where I should use this event(try .. except)?
   
If this is not good way or you have a better solution please describe it  for me(please clarify what I should do)?

Thanks a lot.
m.reza
0
 
ImbeginnerAuthor Commented:
for high trust i select onposterror.

thanks for everythning.
in my idea, the real expert  who  can transfer his(or her)engineer ideas to others(not only solve a problem).
you are really a expert.

i wish you will be successful in every stage of your life.

thanks again and have a good time.

m.reza




0
All Courses

From novice to tech pro — start learning today.