BOEING39
asked on
MARKUP PAGE SELECT STATEMENT
Please see the attached Select Statement from a markup page with a date range selection calendars. My issue is when I select the date range and run the GridView query it is not restricting the range to those dates selected. It is returning all the data meeting the parameter restrictions.
SelectCommand="SELECT [ID], [AOSdate], [Ship], [History], [Sta], [Reason1], [Updated], [Created] FROM [AOS] WHERE (([AOSdate] >= @AOSdate) AND ([AOSdate] <= @AOSdate2) AND ([History] = @History) OR ([History] = @History2)) ORDER BY [History], [AOSdate] DESC">
<SelectParameters>
<asp:ControlParameter ControlID="txtstart" Name="AOSdate" PropertyName="Text" Type="DateTime" />
<asp:ControlParameter ControlID="txtend" Name="AOSdate2" PropertyName="Text" Type="DateTime" />
<asp:Parameter DefaultValue="AOG" Name="History" Type="String" />
<asp:Parameter DefaultValue="ETR - Update Required" Name="History2" Type="String" />
</SelectParameters>
SelectCommand="SELECT [ID], [AOSdate], [Ship], [History], [Sta], [Reason1], [Updated], [Created] FROM [AOS] WHERE (([AOSdate] >= @AOSdate) AND ([AOSdate] <= @AOSdate2) AND ([History] = @History) OR ([History] = @History2)) ORDER BY [History], [AOSdate] DESC">
<SelectParameters>
<asp:ControlParameter ControlID="txtstart" Name="AOSdate" PropertyName="Text" Type="DateTime" />
<asp:ControlParameter ControlID="txtend" Name="AOSdate2" PropertyName="Text" Type="DateTime" />
<asp:Parameter DefaultValue="AOG" Name="History" Type="String" />
<asp:Parameter DefaultValue="ETR - Update Required" Name="History2" Type="String" />
</SelectParameters>
ASKER
Here is what I have; however, it is still rendering everything as you indicated.
SelectCommand="SELECT [ID], [AOSdate], [Ship], [History], [Sta], [Reason1], [Updated], [Created] FROM [AOS] WHERE (([AOSdate] >= @AOSdate) AND ([AOSdate] <= @AOSdate2) OR (([History] = @History) OR ([History] = @History2))) ORDER BY [History], [AOSdate] DESC"
SelectCommand="SELECT [ID], [AOSdate], [Ship], [History], [Sta], [Reason1], [Updated], [Created] FROM [AOS] WHERE (([AOSdate] >= @AOSdate) AND ([AOSdate] <= @AOSdate2) OR (([History] = @History) OR ([History] = @History2))) ORDER BY [History], [AOSdate] DESC"
Hi,
I am on mobile therefore hard to paste code but please change the first OR in your select statement to an AND
I am on mobile therefore hard to paste code but please change the first OR in your select statement to an AND
ASKER
Tried No Help.
try the below one
SelectCommand="SELECT [ID], [AOSdate], [Ship], [History], [Sta], [Reason1], [Updated], [Created] FROM [AOS] WHERE
((([AOSdate] >= @AOSdate) AND ([AOSdate] <= @AOSdate2)) OR (([History] = @History) OR ([History] = @History2))
) ORDER BY [History], [AOSdate] DESC"
SelectCommand="SELECT [ID], [AOSdate], [Ship], [History], [Sta], [Reason1], [Updated], [Created] FROM [AOS] WHERE
((([AOSdate] >= @AOSdate) AND ([AOSdate] <= @AOSdate2)) OR (([History] = @History) OR ([History] = @History2))
) ORDER BY [History], [AOSdate] DESC"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Sorry it took so long to get back with you. That tool care of the issue. I had an extra bracket in the code.
Again thanks for your assistance.
Again thanks for your assistance.
without seeing the raw data, I assume your query will return everything from the condition:
([History] = @History2)
You might try to use this:
Open in new window
by encapsulating([History] = @History) OR ([History] = @History2)
in parentheses so that both together are part of the surrounding AND filter.
HTH
Rainer