As for this issue, because I didn’t install MySQL database in my machine, so I can’t test your code on my side. But, from your code, I suggest you could try to use
Convert.ToBase64String() method to convert the passportImage1. The following code is used to display the binary image from SQL database, you could refer to it.
byte[] bytes = (byte[])GetData("SELECT Data FROM tblFiles WHERE Id =" + id).Rows[0]["Data"];
string base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
Image1.ImageUrl = "data:image/png;base64," + base64String;
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
All-Star
45489 Points
7008 Posts
Microsoft
Re: how to save and retrieve images from mysql database
Feb 03, 2015 10:19 PM|Zhi Lv - MSFT|LINK
Hi EasyHero,
As for this issue, because I didn’t install MySQL database in my machine, so I can’t test your code on my side. But, from your code, I suggest you could try to use Convert.ToBase64String() method to convert the passportImage1. The following code is used to display the binary image from SQL database, you could refer to it.
For more details, please see: http://www.aspsnippets.com/Articles/Display-image-from-database-in-Image-control-without-using-Generic-Handler-in-ASPNet.aspx
Best Regards,
Dillion
mysql asp.net