Click here to Skip to main content
15,895,777 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Sir,i save .mht file in mysql data base.Now i want to retrive .mht file from database and show in web page.

my code.......
protected void Button1_Click(object sender, EventArgs e)
{
MySqlConnection con = new MySqlConnection("Server=Localhost;DataBase=password1;user=root;password=nectar");
string strcon = "select data from sla11 where idSLA11=2";
MySqlCommand com = new MySqlCommand(strcon, con);
con.Open();

MySqlDataReader dr = com.ExecuteReader();
if (dr.Read())
{
Response.ContentType = "text/mht";
Response.AddHeader("Content-Disposition", "attachment;name=\"" + dr["data"] + "\"");
Response.BinaryWrite((byte[])dr["data"]);

Response.End();
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Report Not Exist')</script>");
}
con.Close();
Posted

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