Greeting
I created a button, when an Admin click on it call stored procedure to do this step:
===> Modify Column value [Bit] from true to False when a records came old than 30 days.
What happen?
when I click on button a page refresh, but a rows in table not modfiy ( change column value)
Button code:
- protected void SChJ_Click(object sender, EventArgs e)
- {
- string connectionString = @"Data Source=(local)\SQLEXPRESS;AttachDbFilename=|DataDirectory|\land.mdf;Integrated Security=True";
- using (SqlConnection sqlcon = new SqlConnection(connectionString))
- {
- try
- {
- sqlcon.Open();
- SqlCommand sqlcmd = new SqlCommand("get_expir_job_date", sqlcon);
- sqlcmd.CommandType = CommandType.StoredProcedure;
- sqlcmd.Parameters.AddWithValue("@C_date", SqlDbType.DateTime);
- sqlcmd.Parameters.AddWithValue("@JEnable", SqlDbType.Bit);
- sqlcmd.ExecuteNonQuery();
- sqlcon.Close();
- }
- catch (Exception ex)
- {
- JobFaUp.Text = ex.ToString();
- }
- }
- }
Stored Procedure Code
- CREATE PROCEDURE [dbo].[get_expir_job_date]
- @C_date datetime, //Create Date
- @JEnable bit //JOb Status Enable or Disable
- AS
- BEGIN
- SELECT * FROM [Jobs]
- Update [Jobs] SET @JEnable='False'
- WHERE
- @C_date > DATEADD(DAY, +30, CURRENT_TIMESTAMP)
- End