I have following stored procedure code when i execute it gives an error saying invalid column name Lat , Lng .These Lat and Lng variables are parameters called from c# code behind with sql query indicated at last in this particular paragraph.
CREATE FUNCTION spherical_distance(@a float, @b float, @c float)
RETURNS float
AS
BEGIN
RETURN ( 6371 * ACOS( COS( (@a/@b) ) * COS( (Lat/@b) ) * COS( ( Lng/@b ) - (@c/@b) ) + SIN( @a/@b ) * SIN( Lat/@b ) ) )
END
create view [dbo].[business] as
SELECT Id,
Name1,
ZipCode,
StreetName,
StreetNumber,
State1,
Lat,
Lng,
Keyword
FROM Business_Details
sqlda.SelectCommand.CommandText = "select *, spherical_distance( Lat, 57.2958, Lng) as distance
from business
where (( distance < '" + radius + "' )
and (StreetName like '%" + streetname + "%')
and (Keyword like '%" + keyword1 + "%' ))
order by spherical_distance(Lat,57.2958,Lng)";