Click here to Skip to main content
15,908,166 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how to implement this in c# asp.net.please help asap...

Edit - asap (urgency) removed
Posted
Updated 26-Oct-15 1:07am
v2
Comments
Patrice T 26-Oct-15 6:46am    
This is not a quick question !
The question is not even correct.
Suvendu Shekhar Giri 26-Oct-15 6:54am    
Please share, what you have tried so far?
F-ES Sitecore 26-Oct-15 7:03am    
Google "asp.net image gallery", there are lots of examples of this already.

1 solution

Following code will give the idea for showing image from database



string roll_no = "Your Search Parameter"
string sConn = System.Configuration.ConfigurationManager.ConnectionStrings["YOUR_CONNECTIONSTRING_NAME"].ToString();
SqlConnection objConn = new SqlConnection(sConn);
objConn.Open();
string sTSQL = "select img from Images where Roll_no=@roll_no";
SqlCommand objCmd = new SqlCommand(sTSQL, objConn);
objCmd.CommandType = CommandType.Text;
objCmd.Parameters.AddWithValue("@roll_no", roll_no.ToString());
object data = objCmd.ExecuteScalar(); //THIS WILL TAKE YOUR IMAGE AS OBJECT
objConn.Close();
objCmd.Dispose();
context.Response.BinaryWrite((byte[])data);//THIS WILL WRITE YOUR IMAGE ON SCREEN


-------------------------------------------------------------------------
Image1.ImageUrl = "ImageHandler.ashx?roll_no=" + txtrollno.Text; //IMAGE URL


=>ImageHandler.ashx // THIS IS A HANDLER WHERE ALL THE ABOVE CODE TO BE WRITTEN
STEPS TO CREATE HANDLER :-
ADD NEW ITEMS =>SELECT GENERIC HANDLER.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900