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
mathieu_cuprykAsked:
Who is Participating?
 
prairiedogConnect With a Mentor Commented:
Your code looks fine to me, it should handle any file format. Maybe the problem resides in a different place.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.