i have stored image in the database.how can i retrieve it a and display in asp.net webform.

am not asking display thru datagrid.i have to put link to those images

plz help me to solve this problem

I did this a few months ago but here is the code I used.

private void Page_Load(object sender, System.EventArgs e)
{
	dbConn = new System.Data.SqlClient.SqlConnection(ConfigurationSettings.AppSettings["connString"]);
	string id = Request.QueryString["id"];
			
	string sCmd = "SELECT Photo FROM t_Student_Photos  WHERE Photo_Id =" + id;
	cmd = new System.Data.SqlClient.SqlCommand(sCmd, dbConn);

	dbConn.Open();
	dbReader = cmd.ExecuteReader();

	if( dbReader.Read())
		{
                 //Reponse.Content type would have to change depending on the type of image
		Response.ContentType = "image\\jpeg";
		Response.BinaryWrite((byte[])dbReader["Photo"]);
		}

	//Close Connection
	dbConn.Close();
}

And then you would simply put viewimage.aspx?id=1234 as the src in your img tag and it would load the required image from the database.

This probably is not the best or most flexible code buit it does work.

If you have an specific questions just shoot.

hey u, i have a question.

i want to save colored bold text in database, i didnt suceed in that
the text is inserted empty in the database, i am using html editor

what is the answer?

thanks

Start your own thread next time...

But put the appropriate HTML tags into the database along with the text.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.