protected void ExportResultToCSV(string fileName)
    {
        ResultDS.SelectCommand = SqlTextBox.Text;
        DataView view = (DataView)ResultDS.Select(DataSourceSelectArguments.Empty);

        if (view == null)
        {
            return;
        }
        Response.Clear();
        Response.ContentType = "text/csv";
        Response.AddHeader("Content-Disposition",
                           string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncodeUnicode(fileName)));
        DbExport.ExportToCsv(view.Table, Response.Output, CsvFormats.Default);
        Response.End();
    }
    protected void ExportResultToExcel(string fileName)
    {
        ResultDS.SelectCommand = SqlTextBox.Text;
        DataView view = (DataView)ResultDS.Select(DataSourceSelectArguments.Empty);

        if (view == null)
        {
            return;
        }
        this.EnableViewState = false;
        Response.Clear();
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition",
                           string.Format("attachment; filename=\"{0}\"", HttpUtility.UrlEncodeUnicode(fileName)));
        DbExport.ExportToExcelHtml(view.Table, Response.Output, ExcelFormats.Default);
        Response.End();
    }
 protected void UpdateResultBtn_Click(object sender, EventArgs e)
 {
     if (SqlTextBox.Text.StartsWith("SELECT", StringComparison.InvariantCultureIgnoreCase))   //we do not allow to execute statements other that SELECT
     {
         try {
             ResultDS.SelectCommand = SqlTextBox.Text;
             ResultDS.Select(DataSourceSelectArguments.Empty);
             ResultLabel.Visible = false;
             ResultGrid.Visible  = true;
             BtnExportHideAndShow(true);
         }
         catch (Exception ex) {
             ResultGrid.Visible  = false;
             ResultLabel.Width   = new Unit("100%");
             ResultLabel.Text    = "Error in SQL statement: " + ex.Message;
             ResultLabel.Visible = true;
         }
     }
 }