Note that there are some explanatory texts on larger screens.

plurals
  1. POI have an asp.net web site and I need to download all tables from that sql database to a cvs file
    primarykey
    data
    text
    <p>I have an asp.net web site and I need to download all tables from that sql database.</p> <p>Curently i have the code to download a table to a cvs file</p> <pre><code> protected void Export(DataTable ds, string DataTableID) { Response.Clear(); Response.Buffer = true; switch (DataTableID) { case "1": Response.AddHeader("content-disposition", "attachment;filename= Table 1.csv"); break; case "2": Response.AddHeader("content-disposition", "attachment;filename= Table 2.cvs"); break; default: Response.AddHeader("content-disposition", "attachment;filename=Default.csv"); break; } Response.Charset = ""; Response.ContentType = "application/text"; StringBuilder sb = new StringBuilder(); for (int k = 0; k &lt; ds.Columns.Count; k++) { //add separator sb.Append(ds.Columns[k].ColumnName + ','); } //append new line sb.Append("\r\n"); for (int i = 0; i &lt; ds.Rows.Count; i++) { for (int k = 0; k &lt; ds.Columns.Count; k++) { //add separator sb.Append(ds.Rows[i][k].ToString().Replace(",", ";") + ','); } //append new line sb.Append("\r\n"); } Response.Output.Write(sb.ToString()); Response.Flush(); Response.End(); } } </code></pre> <p>i would like to execute this function above multiple times times with different table in the sql DB on one button click below</p> <pre><code> protected void Download_Click(object sender, EventArgs e) { using (SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["Configuration"].ToString())) { ////////Table 1 DataTable ds = new DataTable(); Update_ obj = new Update_(); ds = obj.Download_Data("A", cn); Export(ds,"1"); ////////Table 2 DataTable ds8 = new DataTable(); ds8 = obj.Download_Data("2", cn); Export(ds8, "2"); } } </code></pre> <p>The problem is that it will execute for the first table but not the 2nd table i be leave that it is the Response.End(); because that is causing the page to stop executing, any one have any ideas for an alternative. with out the Response.End(); the page throws off an error and never finishes the first table download.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload