自己写了个web service,却得不到想要的结果,请高手进来看一下,急!!
自己的源程序如下:
public string[] name(decimal jingdu, decimal weidu)
{
string[] s = new string[3];
string strconn = "Data Source=ANDY;Initial Catalog=andy;Integrated Security=True ";
SqlConnection conn = new SqlConnection(strconn);
string sqlstr = "select name from jingdian where ID=all(select top 3 ID from jingweidu order by square(longitude- ' " + jingdu + " ')+square(latitude- ' " + weidu + " ')) ";
SqlDataAdapter da = new SqlDataAdapter(sqlstr, conn);
DataSet ds = new DataSet();
da.Fill(ds, "jingdian ");
DataTable dt = ds.Tables[ "jingdian "];
for (int i = 0; i < dt.Rows.Count; i++)
{
s[i] = (string)dt.Rows[i][ "name "];
}
return s;
程序目的是想返回查询jingdian表里的几个name值,结果却出现以下结果:
<string xsi:nil= "true " />
<string xsi:nil= "true " />
<string xsi:nil= "true " />
请高手为我分析一下吧,有点急!
------解决方案--------------------可能是你的sql语句有问题.
all,any是拿过来做比较的时候用.即 "> ", " < ",如果是等于的话只有一个值能查出来.
所以把sql语句改为:select name from jingdian where ID in (select top 3 ID from jingweidu order by square(longitude- ' " + jingdu + " ')+square(latitude- ' " + weidu + " '))
试试