views:

106

answers:

2

I wrote a program running as a service that need to frequently gain access to MS Access database. After a period of time, my program exits automatically, then I open my MS Access database with Office, it says it is broken!

It seems very strange as my program do just some very common database access: insert, select and delete. Why is it always broken after running a period of time?

Has anyone here ever run into such problem? Any advice is appreciated.

+5  A: 

Almost all problems of this nature when dealing with Access (or Excel, Outlook...) are due to not correctly releasing (i.e. cleaning up) resources.

Suggest you post any errors you are seeing.

Mitch Wheat
+3  A: 

Access does not recover gracefully if a program terminates without closing the database. There is a dirty flag that Access uses, and the repair feature will reset it (amongst other things), but typically, I don't recommend Access where any robust handling is required.

Cade Roux
Hi Cade! Thanks for your quick reply!Are you meaning the problem is caused because the program hasn't close the database. Are there any other possible reasons for this problem? I have no other choice except MS Access as our project is based on MS Access database.
Yes, if the program doesn't close the database. Also if the network connection is lost while the file is opened. Also, this might not be caused by your service, but some other program or another instance of your program opening the database and not closing it properly.
Cade Roux