I would like to get a list box value into the ABS “where” if I type it with no parameter it works fine , when I use the value of a list box or even a textbox it don’t work correct .. am I doing something work ?
dosnt work :
SELECT ID, Latitude, Longitude, name, SQRT(POWER(Latitude - @Latitude, 2) + POWER(Longitude - @Longitude, 2)) * 6371 AS DistanceFromAddress,
FROM Stores
WHERE (ABS(Latitude - @Latitude) < @lstkm) AND (ABS(Longitude - @Longitude) < @lstkm) AND (online = 'true')
ORDER BY DistanceFromAddress
Work :
SELECT ID, Latitude, Longitude, name, SQRT(POWER(Latitude - @Latitude, 2) + POWER(Longitude - @Longitude, 2)) * 6371 AS DistanceFromAddress, FROM Stores
WHERE (ABS(Latitude - @Latitude) < 0.10) AND (ABS(Longitude - @Longitude) < 0.10) AND (online = 'true')
Just like @oned_gk said, please check your datatype of @lstkm. I test your where clause with my sample data, it works fine.
Please check.
declare @table table( id int identity(1,1), Latitude decimal(8,3),Longitude decimal(8,3), online varchar(10))
insert into @table
select 10.2,12.9,'true' union all
select 10.2,10.9,'true' union all
select 10.2,12.8,'true'
declare @latitude decimal(8,3), @longitude decimal(8,3), @lstkm decimal(5,2)
set @latitude = 10.29
SET @longitude = 12.85
SET @lstkm = 0.1
SELECT * from @table
WHERE (ABS(Latitude - @Latitude) < @lstkm) AND (ABS(Longitude - @Longitude) < @lstkm)
AND (online = 'true')
Thanks.
Please mark the replies as answers if they help or unmark if not.
Feedback to us
indeed , what oned_gk said was correct , i change the datatype and it works fine.
Now the other thing is I have another rb list , with only strings(one word) , but there is not working despite the fact I that I made sure the data type is string
Now the other thing is I have another rb list , with only strings(one word) , but there is not working despite the fact I that I made sure the data type is string
Hi,
Would you please show us your that part code? It will provide us more information about your issue.
Thanks.
Please mark the replies as answers if they help or unmark if not.
Feedback to us
orhaii
0 Points
11 Posts
ABS parameters list box SQL asp vb
Nov 06, 2012 11:58 AM|LINK
I would like to get a list box value into the ABS “where” if I type it with no parameter it works fine , when I use the value of a list box or even a textbox it don’t work correct .. am I doing something work ?
dosnt work :
SELECT ID, Latitude, Longitude, name, SQRT(POWER(Latitude - @Latitude, 2) + POWER(Longitude - @Longitude, 2)) * 6371 AS DistanceFromAddress,
FROM Stores
WHERE (ABS(Latitude - @Latitude) < @lstkm) AND (ABS(Longitude - @Longitude) < @lstkm) AND (online = 'true')
ORDER BY DistanceFromAddress
Work :
SELECT ID, Latitude, Longitude, name, SQRT(POWER(Latitude - @Latitude, 2) + POWER(Longitude - @Longitude, 2)) * 6371 AS DistanceFromAddress, FROM Stores
WHERE (ABS(Latitude - @Latitude) < 0.10) AND (ABS(Longitude - @Longitude) < 0.10) AND (online = 'true')
ORDER BY DistanceFromAddress
oned_gk
All-Star
36078 Points
7363 Posts
Re: ABS parameters list box SQL asp vb
Nov 06, 2012 01:16 PM|LINK
Suwandi - Non Graduate Programmer
Chen Yu - MS...
All-Star
21829 Points
2513 Posts
Microsoft
Re: ABS parameters list box SQL asp vb
Nov 13, 2012 07:29 AM|LINK
Hi,
Just like @oned_gk said, please check your datatype of @lstkm. I test your where clause with my sample data, it works fine.
Please check.
Thanks.
Feedback to us
Develop and promote your apps in Windows Store
orhaii
0 Points
11 Posts
Re: ABS parameters list box SQL asp vb
Nov 13, 2012 09:55 AM|LINK
indeed , what oned_gk said was correct , i change the datatype and it works fine.
Now the other thing is I have another rb list , with only strings(one word) , but there is not working despite the fact I that I made sure the data type is string
thnx alot
Chen Yu - MS...
All-Star
21829 Points
2513 Posts
Microsoft
Re: ABS parameters list box SQL asp vb
Nov 14, 2012 01:21 AM|LINK
Hi,
Would you please show us your that part code? It will provide us more information about your issue.
Thanks.
Feedback to us
Develop and promote your apps in Windows Store
orhaii
0 Points
11 Posts
Re: ABS parameters list box SQL asp vb
Nov 15, 2012 06:27 AM|LINK
RdList
<asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID="rblist" DataTextField="Typeloc" DataValueField="Typeloc"> </asp:RadioButtonList> <asp:SqlDataSource ID="rblist" runat="server" ConnectionString="<%$ ConnectionStrings:LocationsConnectionString %>" SelectCommand="SELECT DISTINCT Typeloc FROM Stores"></asp:SqlDataSource>
SelectCommand="SELECT Typeloc, SQRT(POWER(Latitude - @Latitude, 2) + POWER(Longitude - @Longitude, 2)) * 6371 AS DistanceFromAddress FROM Stores WHERE (ABS(Latitude - @Latitude) < @Lstboxkm) AND (ABS(Longitude - @Longitude) < @Lstboxkm) AND (online = 'true') AND (Typeloc = @Typeloc, ) ORDER BY DistanceFromAddress"> <SelectParameters> <asp:Parameter Name="Latitude" /> <asp:Parameter Name="Longitude" /> <asp:ControlParameter ControlID="Lstboxkm" DefaultValue="1.50" Name="Lstboxkm" PropertyName="SelectedValue" Type="double" />
<asp:ControlParameter ControlID="RadioButtonList1" Name="Typeloc" PropertyName="SelectedValue" Type="String" />
</SelectParameters>