String connString = System.Configuration.ConfigurationManager.ConnectionStrings["web"].ToString(); using (conn = new MySqlConnection(connString)) { using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM avance_presupuestario where proyecto ='" + proy2.Text + "'")) { using (MySqlDataAdapter sda = new MySqlDataAdapter()) { cmd.Connection = conn; sda.SelectCommand = cmd; using (DataTable dt = new DataTable()) { sda.Fill(dt); using (XLWorkbook wb = new XLWorkbook()) { wb.Worksheets.Add(dt, proy2.Text); Response.Clear(); Response.Buffer = true; Response.Charset = ""; Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; Response.AddHeader("content-disposition", "attachment;filename=Avance Presupuestario.xlsx"); using (MemoryStream MyMemoryStream = new MemoryStream()) { wb.SaveAs(MyMemoryStream); MyMemoryStream.WriteTo(Response.OutputStream); Response.Flush(); Response.End(); } } } } } }
using (MySqlCommand cmd = new MySqlCommand("SELECT * FROM avance_presupuestario where proyecto = @proyecto")) { cmd.Parameters.AddWithValue("@proyecto", proy2.Text); ... }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)