Tough one here - I'm creating a web app where users can select multiple reports (via checkboxes), and the app generates them as .html files. I want to open reports in new tabs (users are using IE7. Here is the subroutine I have so far:
Code:
Sub createReportFile(ByVal filename As String)
        Dim reportFile As String = "c:\Reports\" + Replace(filename, "/", "-") + ".html"
        File.WriteAllText(reportFile, code)
        Dim imageBytes As Byte() = File.ReadAllBytes(reportFile)
        Dim mimeType As String = "text/html"
        ' Save report in database
        Dim sqlcommand As String = "INSERT INTO Reports VALUES(" + _
"NEWID(), @campaignid, @filename, @mime, @filebytes, @dateuploaded)"
        Dim cmd0 As New SqlCommand(sqlcommand, cn0)
        cmd0.Parameters.AddWithValue("@filename", Path.GetFileName(reportFile))
        cmd0.Parameters.AddWithValue("@mime", mimeType)
        cmd0.Parameters.AddWithValue("@filebytes", imageBytes)
        cmd0.Parameters.AddWithValue("@dateuploaded", Date.Now.ToString)
        cmd0.Parameters.AddWithValue("@campaignid", Session("CampaignID"))
        cn0.Open()
        cmd0.ExecuteNonQuery()
        ' Open it
        Response.Clear()
        Response.ContentType = mimeType
        Response.AddHeader("Content-Disposition", "attachment;filename=" & Path.GetFileName(reportFile))
        Response.OutputStream.Write(imageBytes, 0, imageBytes.Length)
        Response.End()
        ' Clean up
        cn0.Close()
        imageBytes = Nothing
        mimeType = Nothing
        reportFile = Nothing
        code = Nothing
        donorCriteria = ""
    End Sub
Two bad things are happening with this code:
1. Only the first report generates and saves to the database if multiple ones are selected.
2. The report is generated in the same tab/window as the application.

Please help!