Goran Bibic

Goran Bibic

  • 479
  • 2.9k
  • 197.9k

Select image from db ms sql c#

Jan 1 2019 6:19 AM
Need to select image from  db
 
On my code result is   System.Byte[]
 
I need to display picture
 
Some help?
 
Thank you
  1. string memorandum = "";  
  2.   
  3.             using (SqlConnection openCon = new SqlConnection(con))  
  4.             {  
  5.                 SqlDataReader reader;  
  6.                 SqlCommand cmd = new SqlCommand("SELECT memorandum from dbo.podaci_o_korisniku");  
  7.                   
  8.                 cmd.Connection = openCon;  
  9.                 openCon.Open();  
  10.                 reader = cmd.ExecuteReader();  
  11.   
  12.                 while (reader.Read())  
  13.                 {  
  14.                     byte[] ap = (byte[])podaci_o_korisnikuDataGridView.SelectedRows[0].Cells["memorandum"].Value;  
  15.                     memorandum = reader[0].ToString();  
  16.   
  17.                 }  
  18.                 openCon.Close();  
  19.             } 
 

Answers (9)