开发者

In webService call Procedure after every 2Hour

HI Friends,

I have a create a webservice and call a SQL Procedure from that service and Load the 开发者_运维百科DataTable.

Now, My requirement that i have call that procedure (Update DataTable) after every 2 Hour


You're going to have to create another process that you can schedule to call your web service. It could be as simple as a console app that hits your web service (which in turn updates your table) that you make a scheduled Windows task.


You can have SQL Server schedule a job to execute your stored procedure: How to schedule a stored procedure?.

Another alternative, albeit more work, is to write a Windows service that uses System.Timers.Timer to invoke your stored proc.


There are two possible things going on here.

1) You need to do something to a table every two hours.

2) You need to be sure that whenever people use your WebService, something that it's results depend on is no older than 2 hours

(1) is not something you can do with a "service". A service is something that is accessed on demand, so it can't natively start itself every two hours. You could, however, set up a separate process that did something every two hours, in any number of different ways, like a windows scheduled task.

(2) is quite easy, you can just keep a record somewhere (in the database, e.g.) of the last time "Update DataTable" was done, and if it has not been done within the last 2 hours, just do it then, and then continue with your usual WebService business.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜