Note that there are some explanatory texts on larger screens.

plurals
  1. POInserting a image from a url into database
    primarykey
    data
    text
    <p>Sorry for the supposedly easy question I am trying to insert a picture from a url into the database. Here alb.picture needs to be inserted. </p> <pre><code>url = "https://graph.facebook.com/me/albums/?access_token=" + oAuth.Token; json = oAuth.WebRequest(oAuthFacebook.Method.GET, url, String.Empty); Albums albms = js.Deserialize&lt;Albums&gt;(json); foreach (Album alb in albms.data) { alb.picture = "https://graph.facebook.com/" + alb.id + "/picture/?access_token=" + oAuth.Token; FileStream fs; string sfn = alb.picture; //FileInfo filImage = new FileInfo(sfn); m_lImageFileLength = alb.picture.Length; m_barrImg = new Byte[Convert.ToInt32(m_lImageFileLength)]; **fs = new FileStream(sfn, FileMode.Open, FileAccess.Read);** // this is where it gives me an error abt sfn. C:\win...\sfn path not found fs.Read(m_barrImg, 0, System.Convert.ToInt32(m_lImageFileLength)); insert_Facebook_Photos(Convert.ToInt64(ui.id), m_barrImg, alb.created_time.ToString(), alb.updated_time.ToString()); fs.Close(); private void insert_Facebook_Photos(Int64 FacebookUserID, byte[] picbyte, string created_time, string updated_time) { string conString = "Data Source=HOME-590392F5B5\\SQLEXPRESSR2;Initial Catalog=FMM;Integrated Security=True"; SqlConnection sqlConnection1 = new SqlConnection(); sqlConnection1.ConnectionString = conString; SqlCommand sqlCommand1 = new SqlCommand(); try { sqlConnection1.Open(); //if (sqlCommand1.Parameters.Count == 0) { sqlCommand1.CommandText = "INSERT INTO Facebook_Photos(FacebookUserID,Photo,Photo_CreatedDate,Photo_UpdatedDate) values(@ID,@Picture,@createdDate,@UpdatedDate)"; sqlCommand1.Parameters.Add("@ID", System.Data.SqlDbType.Int, 64); sqlCommand1.Parameters.Add("@Picture", System.Data.SqlDbType.Image); sqlCommand1.Parameters.Add("@createdDate", System.Data.SqlDbType.VarChar, 50); sqlCommand1.Parameters.Add("@UpdatedDate", System.Data.SqlDbType.VarChar, 50); } sqlCommand1.Parameters["@ID"].Value = FacebookUserId; sqlCommand1.Parameters["@Picture"].Value = picbyte; sqlCommand1.Parameters["@createdDate"].Value = created_time; sqlCommand1.Parameters["@UpdatedDate"].Value = updated_time; sqlCommand1.ExecuteNonQuery(); } **fs = new FileStream(sfn, FileMode.Open, FileAccess.Read);** // this is where it gives me an error abt sfn. C:\win...\sfn path not found alb.picture is supposed to be inserted and How do I get the path of this image catch (Exception ex) { throw ex; } finally { sqlConnection1.Close(); } } </code></pre> <p>Thanks Smitha</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload