I created a C#
application, this application creates a database on first launch, this database
which is an SQLiteDatabase
will be stored in the project folder. The process of filling this database
takes on a mid-range notebook around 5 to 10 seconds. So it will be slower on low-budget notebooks. There isn't a big chance, but what if somebody force closes the application, while the database
is being created? Or what if a power failure occurs? The result of this will come out in a broken database
, which will never work.
I'am creating my Database
in c#
and also fill it from c#
, this happens within a try
and catch
, should I delete
the Database
whenever the code within the catch
is called? My applications checks at the beginning of the application whether there already is a database
yes or no? if there isn't it will be created.
What should I do? Delete
the database
when an error occurs(code goes trough catch
) or does somebody has a better solution for my problem?
Thanks in advance!
EDIT:
Some answers has been given to me:
I saw the following code, how can I use this code? Should I put the code that creates my database within the CallAMethodThatDoesSomeWork method?
using(TransactionScope tran = new TransactionScope()) {
CallAMethodThatDoesSomeWork();
CallAMethodThatDoesSomeMoreWork();
tran.Complete();
}