Shiva Tiwari

Shiva Tiwari

  • 1.9k
  • 43
  • 576

I want to insert selected image into database

May 29 2020 2:36 AM
  1. public void BindImages()   
  2. {   
  3. try   
  4. {   
  5. string query = "select * from Images where Prod_id=@Id";   
  6. SqlCommand cmd = new SqlCommand(query, EcomConString);  
  7. cmd.Parameters.AddWithValue("@Id", SqlDbType.VarChar).Value = id;  
  8. cmd.CommandType = CommandType.Text;   
  9. SqlDataAdapter sda = new SqlDataAdapter(cmd);   
  10. DataTable dt = new DataTable();  
  11. sda.Fill(dt);   
  12. if (dt.Rows.Count > 0)   
  13. {   
  14. foreach (DataRow dr in dt.Rows)   
  15. {  
  16. strImages += @"<li><img src='/" + dr["Img"] + @"'  class='img-thumbnail' alt=''  /></li>";strThumbImage += dr["Img"].ToString() + ",";   
  17. }   
  18. }   
  19. }   
  20. catch (Exception ex) { }   
  21. }   

Brought to you by: JavaScript SDK for Bold BI dashboard and analytics embedding. Free trial.

Answers (4)