Beispiel #1
0
        public AlbumObject[] GetPinNameListByUser(string userId)
        {
            using (SqlConnection conn = new SqlConnection())
            {
                List<AlbumObject> aList = new List<AlbumObject>();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                conn.Open();
                SqlCommand cmd = new SqlCommand("SELECT * FROM Album WHERE UserId = @0", conn);
                cmd.Parameters.Add(new SqlParameter("0", userId));

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        AlbumObject a = new AlbumObject();
                        a.Pin = reader["AlbumPin"].ToString();
                        a.AlbumName = reader["AlbumName"].ToString();
                        a.UserId = reader["UserId"].ToString();
                        aList.Add(a);
                    }
                }
                return aList.ToArray();
            }
        }
Beispiel #2
0
        public AlbumObject[] GetPinNameListByUser(string userId)
        {
            using (SqlConnection conn = new SqlConnection())
            {
                List <AlbumObject> aList = new List <AlbumObject>();
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
                conn.Open();
                SqlCommand cmd = new SqlCommand("SELECT * FROM Album WHERE UserId = @0", conn);
                cmd.Parameters.Add(new SqlParameter("0", userId));

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        AlbumObject a = new AlbumObject();
                        a.Pin       = reader["AlbumPin"].ToString();
                        a.AlbumName = reader["AlbumName"].ToString();
                        a.UserId    = reader["UserId"].ToString();
                        aList.Add(a);
                    }
                }
                return(aList.ToArray());
            }
        }