예제 #1
0
        public void SetRequest(string textRequest)
        {
            SqlConnection connect = DBSQLServerUtils.GetDBConnection();

            connect.Open();

            try
            {
                SqlCommand command = new SqlCommand(textRequest, connect);
                using (SqlDataReader result = command.ExecuteReader())
                {
                    while (result.Read())
                    {
                        Student student = new Student(String.Format($"{result["Name"]}"), String.Format($"{result["Surname"]}"), String.Format($"{result["Patronymic"]}"), Convert.ToInt32(result["Id"]), Convert.ToInt32(result["Rating"]), Convert.ToInt32(result["Age"]));
                        students.Add(student);
                    }
                }
            }
            catch
            {
                //TODO: обработка ошибки
            }
            finally
            {
                connect.Close();
                connect.Dispose();
            }
        }
예제 #2
0
        public void SetRequest(string textRequest)
        {
            SqlConnection connect = DBSQLServerUtils.GetDBConnection();

            connect.Open();

            try
            {
                SqlCommand command = new SqlCommand(textRequest, connect);
                using (SqlDataReader result = command.ExecuteReader())
                {
                    while (result.Read())
                    {
                        listResult.Add(String.Format($"{result["Name"]}"));
                    }
                }
            }
            catch
            {
                //TODO: обработка ошибки
            }
            finally
            {
                connect.Close();
                connect.Dispose();
            }
        }