.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

How can I display a picture in an Image Control?

Posted By: Shweta     Posted Date: June 05, 2010    Points:2   Category :ASP.Net
Hi,

How can I display a picture (stored in a SQL Database, as an Image data-type) in an Image Control?

Thanks,
Shewta

Responses
Author: JH             
Posted Date: June 05, 2010     Points: 5   

Hi,

Can you use below sample code..?


//Retrive image from database
SqlCommand command = connection.CreateCommand())
{
command.CommandText = "SELECT images_col FROM Image_List WHERE Id = @Id";
command.Parameters.AddWithValue("@Id", Id);

connection.Open();
byte[] imageDisplay = (byte[])command.ExecuteScalar();

MemoryStream objStream = new MemoryStream(imageDisplay);
image = Image.FromStream(objStream);
}

ImagePart1.Image = newImage;

otherwise you can use Enterprise Library Data Access Application Block if needed

Thanks


Author: Ashutosh Jha             
Posted Date: December 25, 2013     Points: 20   

Hi,

Please follow the below link- In this tutorial they have explained "How to Show an image saved in a SQL Server table on an ASP.NET Image control".
Hope this will resolve your issue.

http://www.codeproject.com/Articles/271590/Show-an-image-saved-in-a-SQL-Table-on-an-ASP-Net-I


Regards,
Ashutosh Jha
ashutosh741@gmail.com

http://www.tricksroad.com


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend