• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

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

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
        conn.Open()
        cmd.ExecuteNonQuery()
        conn.Close()
        SqlConnection.ClearPool(conn)
    End Sub
0
mathieu_cupryk
Asked:
mathieu_cupryk
1 Solution
 
prairiedogCommented:
Your code looks fine to me, it should handle any file format. Maybe the problem resides in a different place.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now