Load image from database in asp net

  • دعنا نشارك هذا :
ترتيب الدرس : 170
المدة : 00:06:49
التحكم :
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 [email protected]
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 csConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection connew SqlConnection(cs))
{
SqlCommand cmdnew SqlCommand("spGetImageById", con);
cmd.CommandTypeCommandType.StoredProcedure;

SqlParameter paramIdnew SqlParameter()
{
ParameterName"@Id",
ValueRequest.QueryString["Id"]
};
cmd.Parameters.Add(paramId);

con.Open();
byte[] bytes(byte[])cmd.ExecuteScalar();
string strBase64Convert.ToBase64String(bytes);
Image1.ImageUrl"data:Image/png;base64," + strBase64;
}
}
}
}

سيتم تفعيل التعليقات قريبا

y
Sep 23, 2020 07:32:27
youtube