【发布时间】:2010-09-01 05:17:58
【问题描述】:
当我执行它时,我有以下存储过程代码给出了一个错误,指出列名无效 Lat 和 Lng。这些 Lat 和 Lng 变量是从后面的 c# 代码调用的参数,最后在这个特定段落中指示了 sql 查询。
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)";
【问题讨论】:
-
您的查询受 Sql Injection 约束。 (当 streetname 变量的值为“ ')); DELETE Business_Details; -- ”,运行 SelectCommand 将清空数据库中的表。)
标签: c# sql sql-server-2005