hai,
i want to retrieve image from sql table which is stored in the format of binary data with image. I just want to display the image in my web page thats all.. im not using with data grid also...
Thanks,
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Raju KatareRank #1,971 · 742 reputationPosted Feb 7, 2011, 11:32 PM EST
Have a look at Handler class of
GridView nested inside another GridView in ASP.NET
article to retrieve the image from database table column of type Varbinary(max). .
Raju KatareRank #1,971 · 742 reputationPosted Feb 8, 2011, 8:37 PM EST
krithika muthukrishnanRank #8,369 · 223 reputationPosted Feb 8, 2011, 11:56 PM EST
hai,
i didn't get the solution,i use this code,it displays the file path of the image,using that file path how to display in a c# file
SqlConnection con = new SqlConnection(@"data source=System-7\sqlExpress;initial catalog=Forum; User ID=sa;Password=as;");
con.Open();
int i = 1;
string query = "select photo from members where userid='"+i+"'";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataReader rdr = null;
rdr=cmd.ExecuteReader();
if ( rdr.Read()) //yup we found our image
{ Response.BinaryWrite((byte[])rdr["photo"]); }
con.Close();
Raju KatareRank #1,971 · 742 reputationPosted Feb 9, 2011, 12:08 AM EST
First you asked that how to display image which is stored in a sql table in the format of Binary Data, then you can get solution to this problem using Handler.ashx Template of ASP.Net (which is there in above article.)
Suthish NairRank #92 · 22.8K reputationPosted Feb 9, 2011, 8:32 AM EST