Click here to Skip to main content
15,905,616 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Sir,i have create a file in excel sheet and than convert into mht file and then save in mysql database.Now i want to retrive mht file from database on webpage...

my code..

C#
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/mhtml";
                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();

it is not open webpage
Posted
Updated 20-Apr-13 1:38am
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