Exemplo n.º 1
0
        public IList <AlbumMaster> GetAlbums()
        {
            List <AlbumMaster> objAlbumList = new List <AlbumMaster>();

            using (SqlCommand scmd = new SqlCommand())
            {
                scmd.Connection  = scon;
                scmd.CommandType = CommandType.Text;
                scmd.CommandText = "SELECT * FROM tblGallery";
                scon.Open();
                SqlDataReader sdr = scmd.ExecuteReader();
                while (sdr.Read())
                {
                    AlbumMaster objAlbumMaster = new AlbumMaster();
                    objAlbumMaster.ImageId   = Convert.ToInt32(sdr["ImageId"]);
                    objAlbumMaster.ImageName = sdr["ImageName"].ToString();
                    objAlbumMaster.Image     = (byte[])sdr["Photo"];
                    objAlbumList.Add(objAlbumMaster);
                }

                if (sdr != null)
                {
                    sdr.Dispose();
                    sdr.Close();
                }
                scon.Close();
                return(objAlbumList.ToList());;
            }
        }
Exemplo n.º 2
0
 public int UploadAlbums(AlbumMaster objAlbumMaster)
 {
     using (SqlCommand scmd = new SqlCommand())
     {
         scmd.Connection  = scon;
         scmd.CommandType = CommandType.Text;
         scmd.CommandText = "INSERT INTO tblGallery(ImageName,Photo) VALUES(@ImageName,@Photo)";
         scmd.Parameters.AddWithValue("@ImageName", objAlbumMaster.ImageName);
         scmd.Parameters.AddWithValue("@Photo", objAlbumMaster.Image);
         scon.Open();
         int status = scmd.ExecuteNonQuery();
         scon.Close();
         return(status);
     }
 }
Exemplo n.º 3
0
 public byte[] GetImageFromDataBase(int id)
 {
     using (SqlCommand scmd = new SqlCommand())
     {
         scmd.Connection  = scon;
         scmd.CommandType = CommandType.Text;
         scmd.CommandText = "SELECT Photo FROM tblGallery where ImageId=@ImageId";
         scmd.Parameters.AddWithValue("@ImageId", id);
         scon.Open();
         SqlDataReader sdr      = scmd.ExecuteReader();
         AlbumMaster   objAlbum = new AlbumMaster();
         while (sdr.Read())
         {
             objAlbum.Image = (byte[])sdr["Photo"];
         }
         return(objAlbum.Image);
     }
 }