Link to home
Start Free TrialLog in
Avatar of mathieu_cupryk
mathieu_cuprykFlag for Canada

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial