Note that there are some explanatory texts on larger screens.

plurals
  1. PONeeding to get a list of strings into a webservice
    primarykey
    data
    text
    <p>I am creating a web service via asp.net. I want to pull as a list the Address's of the Fuel Stops as shown below unfortunately what I am getting is the string name of address's as shown below from the xml...</p> <p>Unfortunately when I do run this I get a xml file filled with </p> <pre><code>-&lt;FuelStop&gt; &lt;Physical_Address_Street&gt;Physical_Address_Street&lt;/Physical_Address_Street&gt; &lt;Physical_Address_Local&gt;Physical_Address_Local&lt;/Physical_Address_Local&gt; &lt;Physical_Address_State&gt;Physical_Address_State&lt;/Physical_Address_State&gt; &lt;Physical_Address_Zip&gt;Physical_Address_Zip&lt;/Physical_Address_Zip&gt; &lt;Phone_Number&gt;Phone_Number&lt;/Phone_Number&gt; &lt;/FuelStop&gt; </code></pre> <p>Versus getting the address info that is populated in the database.</p> <p>Below is my code.</p> <pre><code>Imports System.Web.Services Imports System.Web.Services.Protocols Imports System.ComponentModel Imports System.Data Imports System.Data.SqlClient &lt;System.Web.Services.WebService(Namespace:="http://watersports.com 8010/", Description:="Holds Fuel Stop and Shelter information", Name:="ShelterandFuelService")&gt; _ &lt;System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)&gt; _ &lt;ToolboxItem(False)&gt; _ Public Class Service1 Inherits System.Web.Services.WebService &lt;WebMethod()&gt; _ Public Function GetAddresses(ByVal skip As Integer, ByVal take As Integer) As FuelStop() Dim sqlCon As New SqlConnection Dim resultList = New List(Of FuelStop)() Try sqlCon.ConnectionString = "Data Source=google.watersports.com;Initial Catalog=myDb;Persist Security Info=True;Connect Timeout=30;User ID=****;Password=******" Dim command As New SqlCommand("SELECT @Physical_Address_Street, @Physical_Address_Local, @Physical_Address_State, @Physical_Address_Zip, @Phone_Number FROM Gas_Stations WHERE Location_Type = 1") command.Parameters.Add("@Physical_Address_Street", SqlDbType.VarChar, 50).Value = "Physical_Address_Street" command.Parameters.Add("@Physical_Address_Local", SqlDbType.VarChar, 50).Value = "Physical_Address_Local" command.Parameters.Add("@Physical_Address_State", SqlDbType.VarChar, 50).Value = "Physical_Address_State" command.Parameters.Add("@Physical_Address_Zip", SqlDbType.VarChar, 50).Value = "Physical_Address_Zip" command.Parameters.Add("@Phone_Number", SqlDbType.VarChar, 50).Value = "Phone_Number" command.Connection = sqlCon sqlCon.Open() 'command.ExecuteNonQuery() 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 Catch ex As Exception sqlCon.Close() Finally sqlCon.Close() End Try Return resultList.Skip(skip).Take(take).ToArray() </code></pre> <p>Based on the Sql Command below I will return possibly a few hundred address's how do I incorporparate this into my vb.net logic to return the list of address's?</p> <pre><code>Dim command As New SqlCommand("SELECT Physical_Address_Street, Physical_Address_Local, Physical_Address_State, Physical_Address_Zip, Phone_Number FROM Gas_Stations WHERE Location_Type = 1") </code></pre> <p>And here is my Fuel stop class</p> <pre><code>Public Class FuelStop Property Physical_Address_Street As String Property Physical_Address_Local As String Property Physical_Address_State As String Property Physical_Address_Zip As String Property Phone_Number As String End Class </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload