Timer problem in sql server 2005

Last Post 28 Jul 2012 11:04 AM by rahuls2304. 0 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
rahuls2304
New Member
New Member

--
28 Jul 2012 11:04 AM
I am currently doing the project on "GSM based power meter reading" on which i am implementing the server on sql server 2005. The project is having facility to send the sms to the customer so as to implement this i write the code in such a way that for a particular time set by the server, the sms will send to the user. I dont know why the sms is not going for the particular set time.I tried a lot but not able to find the solution. I am adding the coding along-with this forum.

DataSet ds;
private void timer2_Tick(object sender, EventArgs e)
{
if (DateTime.Now.Hour == 23)
{
qry1 = "select distinct t1.account_no, t1.cust_name, t1.contact_no, convert(varchar(10),t2.reading_date,103) as dt, t2.reading from tblCustomer t1 inner join tblCustMeterReading t2 on t1.account_no = t2.account_no where convert(varchar(10),t2.reading_date,101) ='" + DateTime.Now.Date.ToString("MM/dd/yyyy")+"' and t2.status = 'No'";
ds = cls.GetDataSet(qry1);
foreach(DataRow dr in ds.Tables[0].Rows)
{
MSG = "Dear " + dr[1].ToString() + Environment.NewLine +
"The Current Meter Reading of " + dr[3].ToString() + Environment.NewLine +
"is : " + dr[4].ToString() + " kWh";
objclsSMS.sendMsg(this.port, dr[2].ToString(), MSG);
qry1 = "update tblCustMeterReading set status = 'Yes' where account_no = '" + dr[0].ToString() + "' and convert(varchar(10),reading_date,101) ='" + DateTime.Now.Date.ToString("MM/dd/yyyy") + "' and status ='No'";
cls.ExecuteNonQuery(qry1);
}
}
}

Thanking you.
You are not authorized to post a reply.

Acceptable Use Policy