Exemplo n.º 1
0
        private void SearchComedi()
        {
            Manga.Clear();
            string sqlExpression = "SELECT * FROM Manga where Genre ='Комедия' and user_id =" + User.user.ID;

            if (DataBase.SqlConnection.State != System.Data.ConnectionState.Open)
            {
                DataBase.SqlConnection.Open();
            }

            if (DataBase.SqlConnection.State == System.Data.ConnectionState.Open)
            {
                SqlCommand    command = new SqlCommand(sqlExpression, DataBase.SqlConnection);
                SqlDataReader reader  = command.ExecuteReader();

                if (reader.HasRows)       // если есть данные
                {
                    while (reader.Read()) // построчно считываем данные
                    {
                        object film_id     = reader["Manga_id"];
                        object title       = reader["Title"];
                        object genre       = reader["Genre"];
                        object year        = reader["Year"];
                        object description = reader["Description"];
                        object status      = reader["Status"];


                        Manga.Add(new MangaM(Convert.ToInt32(film_id.ToString()), title.ToString(),
                                             genre.ToString(), Convert.ToInt32(year.ToString()), description.ToString(), status.ToString()));
                    }
                }
                reader.Close();
            }
            DataBase.SqlConnection.Close();
        }