Click here to Skip to main content
15,889,335 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I want to set an action (sending message event) to take place daily once. I wrote the code for sending message in the main Form. So when user opens the application, every time the message will be sent. But I need it to happen only once in a day so the user can login everytime and message is sent only once.

Please provide me the solution and code if possible thanks in advance.

I tried following code but it doesnt work properly
C#
try
{
    // here i try to retrieve date =date.today  from sql table;


                con.Open();
                cmd.CommandText = "select Login_Date from LoginObserver where        Login_Date =" + System.DateTime.Today;
                cmd.ExecuteNonQuery();
                con.Close();
}
// if error enter into the catch block
catch
{

/* this is my code for sending ..but i have not put entire code
   /*code for sending message*/
    sm.sendSMS("number", messagetext);
    
    insert into table where date = datetime.now;
                      con.Open();
                      cmd.CommandText = "Insert Into LoginObserver values('" + 1 + "','" + System.DateTime.Today + "')";
                      cmd.ExecuteScalar();
                      con.Close();

}
But the above code not working. Control flow is not entering the catch block.

Please provide me a solution and code.

Thanks in advance
Posted
Updated 25-Jul-13 18:08pm
v5
Comments
[no name] 25-Jul-13 5:32am    
The code is not working because there is no code there, just comments.
MohRizwan 25-Jul-13 5:49am    
hey i have not put the code just gave you an idea of what i did
[no name] 25-Jul-13 8:14am    
And so? The only thing that your code tells us is that your try block is not throwing any exceptions for you to catch. You have not explained why you think that this is not working "properly"

1 solution

You can set this things in registry for local machine. Set Value in registry when status is the user login on first time on current date. If you code for this let me know
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900