コード例 #1
0
        public void insert(string photoId)
        {
            //Save the Image selected to the database
            List <ImageDetails> detailList = new List <ImageDetails>();
            Flickr    flickr = new Flickr(flickrKey, sharedSecret);
            PhotoInfo info   = flickr.PhotosGetInfo(photoId);

            ImageDetails imgDetail = new ImageDetails();

            imgDetail.id               = info.PhotoId;
            imgDetail.ImageName        = info.Title;
            imgDetail.ImageDescription = info.Description;
            imgDetail.ImageData        = info.SmallUrl;
            imgDetail.ImageDate        = info.DatePosted;
            imgDetail.ImageLocation    = SearchTextBox.Text.ToString();

            detailList.Add(imgDetail);
            AddImageDetail(imgDetail);
        }
コード例 #2
0
        public string AddImageDetail(ImageDetails imgDetail)
        {
            //SQL database Connection String
            string constr = ConfigurationManager.ConnectionStrings["DefaultConnection"].ToString();

            try
            {
                using (SqlConnection con = new SqlConnection(constr))
                {
                    SqlCommand com = new SqlCommand("usp_UploadImage", con);
                    com.CommandType = CommandType.StoredProcedure;
                    com.Parameters.AddWithValue("@ImgID", imgDetail.id);
                    com.Parameters.AddWithValue("@ImgName", imgDetail.ImageName);
                    com.Parameters.AddWithValue("@ImageData", imgDetail.ImageData);
                    com.Parameters.AddWithValue("@ImageDescription", imgDetail.ImageDescription);
                    com.Parameters.AddWithValue("@ImageDate", imgDetail.ImageDate);
                    com.Parameters.AddWithValue("@ImageLocation", imgDetail.ImageLocation);

                    con.Open();
                    int i = com.ExecuteNonQuery();
                    con.Close();
                    return(lblErrors.Text = "Image Added Successfully");
                }
            }

            catch (SqlException ex)
            {
                // display error fot duplicate images
                string str;
                str  = "Source:" + ex.Source;
                str += "\n" + "Message:" + ex.Message;

                lblErrors.Text = str + "Database Exception";
                return(lblErrors.Text = str + "Database Exception");
            }
        }