How to delete data by date range

Aug 16 2017 10:31 PM
Am having a problem in my c sharp application. I want to delete data inside database (am using MSSQL server 2012) between two selected date. But my propblem is, after I click on delete button messageBox shows deleted successfully but when I view the data inside database I still see them which means the data is not deleted. please I need someone to help me. this is my code so far.
 
 
string query = "DELETE FROM TABLE_SALES WHERE DATE >= '" + DateTimee.Value.Date.ToString() + "' AND DATE <= '" + DateTimee2.Value.Date.ToString() + "'";
dt = new DataTable();
sda = new SqlDataAdapter(query, con);
sda.Fill(dt);
dataGridView1.DataSource = dt;
con.Close();
MessageBox.Show("SALES DELETED SUCCESSFULLY", "MESSAGE", MessageBoxButtons.OK, MessageBoxIcon.Information);
 

Answers (2)