Need to be able to add following formats jpg, gif, png, xls, xlsx, doc, docx, txt,csv, zip

Posted on 2008-11-14
Last Modified: 2012-05-05
I need to upload the file formats jpg, gif, png, xls, xlsx, doc, docx, txt,csv, zip

So this retouine only handles xlsx

    Shared Sub AddAttachment(ByVal filename As String, ByVal fileContent As Byte(), ByVal interviewID As Integer)

        Dim sql As New StringBuilder()
        sql.Append("INSERT INTO [tbl_dotnet_attachments]([InterviewID],[Filename],[ImageContent],[DateCreated]) ")
        sql.Append("   VALUES ")
        sql.Append(" (@InterviewID,@FileName,@FileContent,GETDATE() )")
        Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
        Dim cmd As New SqlCommand(sql.ToString(), conn)

        cmd.Parameters.Add("@InterviewID", SqlDbType.Int).Value = interviewID
        cmd.Parameters.Add("@FileContent", SqlDbType.Image).Value = fileContent
        cmd.Parameters.Add("@FileName", SqlDbType.VarChar).Value = filename
    End Sub
Question by:mathieu_cupryk
    1 Comment
    LVL 22

    Accepted Solution

    Your code looks fine to me, it should handle any file format. Maybe the problem resides in a different place.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now