I am trying to save images in a SQL Server database.
I convert the image to byte and store it in SQL Server, but now I would like to convert saved bytes to an image and show it on a label using ASP.NET in C # .
I tried a lot but did not get the solution. / P>
Here is the code (convert the bytes to the image)
if (fImage.HasFile) {if (fImage.PostedFile.ContentType == "image / jpg" || FImage .PostedFile.ContentType == "Image / JPEG"} FIMF.posted file.content type == "image / PNG") {int filelenght = fImage.PostedFile.ContentLength; Byte [] imagebytes = new byte [filelenght]; FImage.PostedFile.InputStream.Read (ImageBit, 0, FileLink); SqlCommand CMD = new SQL Commands (); Cmd.CommandText = "Insert in tbImage (Img) values (@img)"; Cmd.Connection = con; Cmd.Parameters.AddWithValue ("@ img", ImageBit); Con.Open (); Cmd.ExecuteNonQuery (); Con.Close (); reaction. Type ("image saved in database"); }}
to something like byte []
Image
:
MemoryStream MS = new memorystream (byte); Image i = Image Forstream (MS);
Comments
Post a Comment