i have a table as CostData in that i have a column as Month_year which is in mm/dd/yyyy format
and now i want to delete data based on date. suppose i give start date as 01/31/2012
and end Date as 01/31/2013 it should delete whole one years record. and i have to text box’s to take input of start and endDate
(“Delete from CostData where Month_year between {0} and {1}'”, TextBox2.Text, TextBox1.Text)
this is the query that I’m using, but its not working. Month_year is of date type.
Actually, I think you’re issue is with your SQL String. If you posted more of your code, I could tell for sure, but I suspect your using String.Format in the above? If so, just wrap {0} and {1} around apostrophes:
Please look into using parameterized queries — this method is vulnerable to SQL Injection.
Good luck.