Hi All,
I am using the below code to retrieve an varbinary image from a database. Is it possible to display the image into an image editor.
Any idea or sample code
Thanks
I am using the below code to retrieve an varbinary image from a database. Is it possible to display the image into an image editor.
Any idea or sample code
SqlConnection conn = new SqlConnection(strconnection); SqlDataAdapter sda = new SqlDataAdapter("select Front_Image,Rear_Image from Transactions", conn); DataTable dt = new DataTable(); sda.Fill(dt); foreach (DataRow row in dt.Rows) { //Get the byte array from image file byte[] imgBytes = (byte[])row["Front_Image"]; //If you want convert to a bitmap file TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap)); Bitmap MyBitmap = (Bitmap)tc.ConvertFrom(imgBytes); string imgString = Convert.ToBase64String(imgBytes); //Set the source with data:image/bmp Front_img.Src = String.Format("data:image/Bmp;base64,{0}\"", imgString);Thanks
