Student Reviews
( 5 Of 5 )
1 review
Video of Load image from database in asp net in ASP.net course by kudvenkat channel, video No. 170 free certified online
Text version of the video
http://csharp-video-tutorials.blogspot.com/2015/08/load-image-from-database-in-aspnet.html
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation1
Slides
http://csharp-video-tutorials.blogspot.com/2015/08/load-image-from-database-in-aspnet_12.html
All ASP .NET Text Articles
http://csharp-video-tutorials.blogspot.com/p/free-aspnet-video-tutorial.html
All ASP .NET Slides
http://csharp-video-tutorials.blogspot.com/p/aspnet-slides.html
ASP.NET Playlist
https://www.youtube.com/playlist?listPL4cyC4G0M1RQcB4IYS_zwkyBwMyx5AnDM
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view1&sortdd
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists
Tags
c# load image from sql database
asp.net get image from database and display
save and retrieve image from database asp.net c#
In this video we will discuss how to load image from database using asp.net and c#. This is continuation to Part XX. Please watch Part XX from ASP.NET tutorial for beginner.
When we click on "View Uploaded Image" link, the user will be redirected to WebForm2.aspx. The Id of the image will be passed as a query string parameter. In the page load event, we need to retrieve the image from the database and display it on the web page.
Step 1 : Create stored procedure to retrieve image by Id.
Create procedure spGetImageById
@Id int
as
Begin
Select ImageData
from tblImages where Id@Id
End
Go
Step 2 : Drag and drop an Image control on WebForm2.aspx.
<asp:Image ID"Image1" Height"500px" Width"500px" runat"server" />
Step 3 : Copy and paste the following code in WebForm2.aspx.cs
using System;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
namespace Demo
{
public partial class WebForm2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string cs ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con new SqlConnection(cs))
{
SqlCommand cmd new SqlCommand("spGetImageById", con);
cmd.CommandType CommandType.StoredProcedure;
SqlParameter paramId new SqlParameter()
{
ParameterName "@Id",
Value Request.QueryString["Id"]
};
cmd.Parameters.Add(paramId);
con.Open();
byte[] bytes (byte[])cmd.ExecuteScalar();
string strBase64 Convert.ToBase64String(bytes);
Image1.ImageUrl "data:Image/png;base64," + strBase64;
}
}
}
}