Home > Forum > ASP.NET > Need to update the data automatically within the given duration in asp.net

Need to update the data automatically within the given duration in asp.net

by celv   on Oct 17, 2014   Category: ASP.NET  |  Views: 1043    |  Points: 5   |  Bronze 
  Reply
i have 2 tables one is attendance table another one is absent table.in my company employee will come form moring 8AM to 6Pm so after 6Pm i need to update the table automatically at 6PM

Bookmark and Share:
 
  User Reply  | Ask a question  |   Reply 
  Re :Need to update the data automatically within the given duration in asp.net   
by Thamil
on Oct 18 2014 3:18AM
Points : 10
Gold 
Hi celv,

Follow below steps to achieve your requirement.

1. We can achieve this functionality through SQL server scheduled jobs
2. Prepare the stored procedure that’s includes your business logic (updating attendance table & absent table.)
CREATE PROCEDURE MyBackgroundTask
AS
BEGIN

//Your code here

END

3. Once stored procedure is ready then schedule this procedure as job and running in specific time. You can schedule this job by using SQL server agent. In SQL Server Management Studio , once you connected with any database, list of objects would be displayed under the management studio ex (database, Security, Server objects, Replication, Management then SQL server agent)
4. Expand the SQL server agent then right click on Jobs folder then click on New Job
5. Configure your jobs in Job schedule window in step by step. Here you can setup the time when your job( stored procedure) would execute in specific period of days.
6. Place this below code in the Command?textarea in the Steps tab General window
EXEC  dbo.MyBackgroundTask

7. Also refer the below URL for reference how to configure scheduled jobs in SQL server.

http://www.dailycoding.com/posts/step_by_step_guide_to_add_a_sql_job_in_sql_server_2005.aspx
http://www.wiseowl.co.uk/blog/s231/schedule_data_import_in_sql_server_pt3.htm
http://stackoverflow.com/questions/1216272/how-to-execute-a-stored-procedure-in-a-sql-agent-job
http://www.quackit.com/sql_server/tutorial/sql_server_agent_jobs.cfm


Let me know if you find any difficulties on this.

Thanks.
  Re :Need to update the data automatically within the given duration in asp.net   
by celv
on Oct 18 2014 10:15PM
Points : 10
Bronze 
how to add job in sql server 2005 . in that am having

Database
security
server objects
replication
management

how to add the attachement in this forum
  Re :Need to update the data automatically within the given duration in asp.net   
by Thamil
on Oct 19 2014 12:55AM
Points : 10
Gold 
Hi celv,

You will find the SQL server agent below the management. first need to verify whether sql server agent is running or not.
  Re :Need to update the data automatically within the given duration in asp.net   
by Thamil
on Oct 19 2014 1:01AM
Points : 10
Gold 
Also you can use the below script to create job in the sql server. Before make sure that you will have rights to create jobs in sql server.
USE msdb –-Your Database name
GO
-- Create Job
EXEC dbo.sp_add_job @job_name = N'Job_Test'

GO

-- Create Job Step 1

EXEC sp_add_jobstep
@job_name = N'Job_Test',
@step_name = N'Step1',
@on_success_action= 1,
@command = N'exec dbo.MyBackgroundTask' -- Stored procedure name

-- Create the schedule to run at 07PM

EXEC dbo.sp_add_schedule
@schedule_name = N'Test-schedule',
@freq_interval = 1,
@freq_type = 4,
@active_start_time = 190000

-- Attach schedule to job

EXEC sp_attach_schedule
@job_name = N'Job_Test',
@schedule_name = N'Test-schedule'

GO
  Re :Need to update the data automatically within the given duration in asp.net   
by celv
on Oct 19 2014 3:40AM
Points : 10
Bronze 
sql server agent is not found in my sql server
  Re :Need to update the data automatically within the given duration in asp.net   
by celv
on Oct 19 2014 4:40AM
Points : 10
Bronze 
http://stackoverflow.com/questions/931252/ajax-autosave-functionality


refer this link its for a textbox . i need to update the table data


i have the following code also

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body
{
font-family: Arial;
font-size: 10pt;
}
table
{
border: 1px solid #ccc;
}
table th
{
background-color: #F7F7F7;
color: #333;
font-weight: bold;
}
table th, table td
{
padding: 5px;
border-color: #ccc;
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
var inter;
window.onload = function () {
inter = setInterval(CheckTime, 1000);
}
function CheckTime() {
var hours = new Date().getHours();
var hours = (hours + 24) % 24;
var mid = 'AM';
if (hours == 0) { //At 00 hours we need to show 12 am
hours = 12;
}
else if (hours > 12) {
hours = hours % 12;
mid = 'PM';
}
var currentTime = hours + ' ' + mid;
if (currentTime == "9 AM") {
$('[id*=GridView1] tr:not(:first)').each(function () {
var customer = {};
customer.CustomerId = $(this).find("td:first").html();
customer.Name = $(this).find("td:nth-child(2)").html();
customer.Country = $(this).find("td:last").html();
$.ajax({
type: "POST",
url: "Default.aspx/SaveUser",
data: '{customer: ' + JSON.stringify(customer) + '}',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {

}
});
});
clearInterval(inter);
}
}

</script>
</head>

</html>

Recent Post

Latest Posts