Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi File Retreival from SQL table

Status
Not open for further replies.

Halliarse

IS-IT--Management
Jan 8, 2007
213
GB
Afternoon, I'm hoping I am in the right forum, if not, could someone please advise.

I have an ASP.Net application, using VB to code. I am creating client invoices and saving the PDF version in a SQL table.
My users have an option to be able to Email the invoices to the respective client, and that, I believe I can acheive! I am retrieving the data using the following code:

Code:
Dim Filename As String = String.Empty
        Dim ByteData As Byte() = Nothing

        Dim cmd As New SqlCommand("Select * from InvoiceFiles where FileID = '" & DropDownList2.SelectedValue & "'", New SqlConnection(constr))

        cmd.Connection.Open()
        Dim reader As SqlDataReader = cmd.ExecuteReader

        If reader.HasRows Then
            While reader.Read
                Filename = reader.Item("Name").ToString & ".pdf"
                ByteData = DirectCast(reader.Item("Data"), Byte())
            End While
        End If

        reader.Close()

        Response.Clear()
        Response.Buffer = True
        Response.ContentType = "application/pdf"
        Response.AddHeader("content-disposition", "attachment;filename=" + Filename)
        Response.Charset = ""
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Response.BinaryWrite(ByteData)
        Response.Flush()
        Response.[End]()

        DropDownList2.Enabled = False

This takes my file and drops it in the Download folder. The issue I have is that in some instances, the invoice needs to be accompanied by a further file, in this case a spreadsheet. I have proved that I can retrieve the spreadsheet if I do it in isolation, however, I need to retreive both the files at the same time. I will then attach both files to the Email, send it and then remove both files from the Download folder.

For further clarification, this is intended as an in-house, web-based product and will only be published internally.

Is what I'm trying to acheive possible? Am I going down the wrong route?

Many thanks from an ASP.NET novice!
 
What cases do you need to attach a spreadsheet. Is it associated with the PDF in the table? What is your table(s) structure and relationships?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top