123456789101112131415161718192021222324252627282930 |
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.Data.SqlClient;
- namespace WebApplication1.Controllers
- {
- [ApiController]
- [Route("[controller]")]
- public class WeatherForecastController : ControllerBase
- {
- static public SqlConnection SqlConnection = new SqlConnection("Data Source=ngknn.ru;Initial Catalog=AAAnobldemo;User ID=21p;Password=12357;Connect Timeout=30;Encrypt=False;Trust Server Certificate=True;Application Intent=ReadWrite;Multi Subnet Failover=False");
-
- [HttpGet(Name = "GetWeatherForecast")]
- public List<string> GetRegion()
- {
- SqlConnection.Open();
- SqlCommand sqlCommand = new SqlCommand("select NameRegion from Region", SqlConnection);
- List<string> list = new List<string>();
- SqlDataReader reader = sqlCommand.ExecuteReader();
- while (reader.Read())
- {
- list.Add(reader.GetString(0));
- }
- SqlConnection.Close();
- reader.Close();
- return list;
- }
- }
- }
|