开发者

How to make a change in Back End Database When my computer turn off by any fault

i have one windows form application in v s 2010. i want to maintain a FLAG in Which there is two values of FLAG

1) yes and 2) no

i want that when a form is load a Flag value is yes and The form is close the flag value is no in my back end Database

It is same like sing in person on any web site.....

But my Problem is that how can i maintain开发者_JAVA百科 it any how the my computer is turn off ....... i store a database on single computer that is server.but i also want a code for on same computer,also


I would do it the opposite way: when your application exits gracefully, write a certain value to your database. When you start your application and do not find this value, you know that your application exited unexpected, e.g. by an apprupt power loss of your computer.


I think what you want is keep a record of whether your application are online.So when your app start,it switch the flag in database to yes,when app close,it switch the flag to no,right? But if the application close abnormally,it may not have the change to switch the flag,this is what we need to handle.

I suggest you attach a timestamp field with the flag in database,and if your app is running,update the timestamp in a fix period,like send a heart beat to database.

Actually we can remove the flag,just use the time stamp field.It store the last heart beat the app sent to the database.

Then we check this last heart beat time,if it's longer than the heart beat interval,we know the client application is closed,disconnected,or down for some reason.

It's not 100% accurate in all time,but it works.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜