Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Route("api/cities/")]
- public IHttpActionResult GetCitiesNames()
- {
- List<String> list = new List<String>();
- SqlConnection conn = new SqlConnection(CONNSTRING);
- conn.Open();
- SqlCommand cmd = new SqlCommand("SELECT DISTINCT(city) FROM Data", conn);
- SqlDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- list.Add(reader["city"].ToString());
- }
- if (list.Count <= 0)
- {
- reader.Close();
- conn.Close();
- return NotFound();
- }
- reader.Close();
- conn.Close();
- return Ok(list);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement