0
我目前有一個web服務,我已經在Visual Studio 2010中構建了一個asmx web服務。目前,當我用我的android應用程序查詢web服務時,我從數據庫中獲取指定數量的地址。我需要的是Android應用程序將用戶當前位置傳遞給Web服務,並讓它返回數據庫中最近地址的10個列表,但我該如何做?我有一個asp.net .asmx webservice,我需要返回最接近客戶端查詢web服務的地址列表
下面是我有那個查詢的數據庫的方法。
<WebMethod()> _
Public Function GetFuelStops(ByVal skip As Integer, ByVal take As Integer) As FuelStop()
Dim resultList = New List(Of FuelStop)()
Using sqlCon As New SqlConnection()
sqlCon.ConnectionString = "Data Source=(local);Initial Catalog=****;User ID=****;Password=***(***"
Dim sql = <sql>
SELECT
[Physical_Address_Street]
, [Physical_Address_Local]
, [Physical_Address_State]
, [Physical_Address_Zip]
, [Phone_Number]
FROM Gas_Stations
WHERE Location_Type = 1
</sql>
Dim command As New SqlCommand()
command.CommandText = CStr(sql)
command.Connection = sqlCon
sqlCon.Open()
Using reader = command.ExecuteReader()
While reader.Read()
Dim fuelStop = New FuelStop()
fuelStop.Physical_Address_Street = reader.GetString(0)
fuelStop.Physical_Address_Local = reader.GetString(1)
fuelStop.Physical_Address_State = reader.GetString(2)
fuelStop.Physical_Address_Zip = reader.GetString(3)
fuelStop.Phone_Number = reader.GetString(4)
resultList.Add(fuelStop)
End While
End Using
End Using
Return resultList.Skip(skip).Take(take).ToArray()
任何示例?代碼明智。 – yams 2013-04-24 20:57:25