私は現在、Visual Studio 2010 で asmx Web サービスとして Visual Basic で構築した Web サービスを持っています。現在、Android アプリで Web サービスをクエリすると、指定された数のアドレスがデータベースから取得されます。Androidアプリがユーザーの現在の場所をWebサービスに渡し、データベース内の最も近い住所の10のリストを返すようにする必要がありますが、どうすればよいですか?
以下は、そのクエリがデータベースである方法です。
<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()