HI
I have dropdownlists that I can select date from those and when I click button It show data from database that their date column is between 2 date i.e 2012-04-1 and 2012-05-30
refer below thread
search-Data-between-2-Date/
SP
USE [behtop]
GO
/****** Object: StoredProcedure [dbo].[searchPic] Script Date: 05/14/2013 17:47:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[searchPic]
@Year int,
@month int,
@day int,
@YearE int,
@monthE int,
@dayE int
AS
BEGIN
select Name,BehCode,Date from House_p
WHERE (YEAR([DATE]) BETWEEN @Year AND @YearE)
AND (MONTH([DATE]) BETWEEN @Month AND @MonthE)
AND (DAY([DATE]) BETWEEN @Day AND @DayE)
END
AND BEhind COde
protected void Btn_Click(object sender, EventArgs e)
{
SqlCommand _cmd = new SqlCommand("searchPic", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cmd.Parameters.AddWithValue("@Year", DDLYear.SelectedItem.Text);
_cmd.Parameters.AddWithValue("@Month", DDLMonth.SelectedItem.Text);
_cmd.Parameters.AddWithValue("@Day", DDLDay.SelectedItem.Text);
_cmd.Parameters.AddWithValue("@YearE", DDLYearE.SelectedItem.Text);
_cmd.Parameters.AddWithValue("@MonthE", DDLMonthE.SelectedItem.Text);
_cmd.Parameters.AddWithValue("@DayE", DDLDayE.SelectedItem.Text);
_cn.Open();
SqlDataReader _dr = _cmd.ExecuteReader();
if (_dr.HasRows)
{
DataList1.DataSource = _dr;
DataList1.DataBind();
}
_cn.Close();
House_p Table
Id
|
Name
|
Behcode
|
Date
|
1
|
TV
|
1111
|
2013-04-01
|
2
|
Radio
|
1112
|
2013-04-07
|
3
|
Sofa
|
1113
|
2013-04-27
|
4
|
Furniture
|
1114
|
2013-05-02
|
5
|
Table
|
1114
|
2013-05-03
|
6
|
Iron
|
1111
|
2013-05-15
|
I have 6 DropDownLists that I can select date Year-Month-Day from them
Now problem is
i.e
When I select below date
Start date from DDLYear,DDLMonth,DDLDay== 2013-04-01
End Date from DDLYearE,DDLMonthE,DDLDayE== 2013-05-30
It show all row from table, row with these id =1,2,3,4,5,6
untill now all thing is correct but when I chang start Date (DAY) I mean I change date Like below
Start date=2013-04-05 End DAte 2013-05-30
I Expect show data from below Id
id=2,3,4,5,6
but it show below row
id=2,3,6
I thing there was problem with day becuse when I change day to 05 it show the day after 05 and didn't effect month on it I mean row with below id =1,4,5 day's is before 05 so it didn't show them
What should I do now
Best Regards