i want to make a connection with database which will work on windows form load event
and populate records in datagrid view which are of last five days mean select all records by subtracting 5 days from present date.
plz help me i have no idea.
Loading

Iftikar HussainRank #423 · 5.9K reputationPosted Jul 27, 2013, 10:29 PM EDT
Regards,
Iftikar
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 24, 2013, 3:54 AM EDT
ta mu198 reputationPosted Jul 24, 2013, 4:50 AM EDT
Riyaz AkhtarRank #2,275 · 619 reputationPosted Jul 24, 2013, 5:04 AM EDT
SELECT * FROM TABLENAME WHERE dateColumnname >= convert(varchar(10), DATEADD(DAY, -5, GETDATE()), 120) AND dateColumnname<=GETDATE()
This query will fetch last 5 days records
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 24, 2013, 5:08 AM EDT
Try like this
select *FROM YourTable DATEDIFF(dd,GETDATE(),YourDateColumn)<=5
Regards,
Iftikar
ta mu198 reputationPosted Jul 25, 2013, 6:52 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 25, 2013, 7:12 AM EDT
string command = "SELECT * FROM Table WHERE DateColumn = '" + dateTimePicker1.Value.AddDays(-5).ToString("dd/MM/yyyy") + "'";
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 25, 2013, 7:37 AM EDT
Regards,
Iftikar
ta mu198 reputationPosted Jul 27, 2013, 10:13 PM EDT
if you can
thank you
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 27, 2013, 10:16 PM EDT
Regards,
Iftikar