- The code in q. returns a single property value not a list/array/collection
- The method returns after the first row in the data has been read
I've stripped the setup code and exception handling to make the changes easier to see.
public List<Properties> FetchCoordinates(String FetchParam)
{
List<properties> props = new List<properties>();
Properties p;
sqlCon.Open();
using (SqlDataReader reader = sqlCom.ExecuteReader())
{
while (reader.Read())
{
p = new Properties()
{ Longitude = reader["Longitude"].ToString(),
Latitude = reader["Latitude"].ToString()};
props.Add(p);
}
}
sqlCon.Close();
return props;
}
Were it me I'd also rename the Properties class "Position" or possibly Coordinate as that seems like a better description given its properties.