Hi everyone!!

I Have the following code to upload files in ASP, but I need this code for vb.net application.
My idea is the same, put the path root in textbox and upload this file to MySQL Database.

Code:
Imports System.IO
Imports System.Data
Imports System.Data.mySqlClient
Imports System.Configuration
Code:
Protected Sub Upload(sender As Object, e As EventArgs)

    Dim filename As String = Path.GetFileName(FileUpload1.PostedFile.FileName)

    Dim contentType As String = FileUpload1.PostedFile.ContentType

    Using fs As Stream = FileUpload1.PostedFile.InputStream

        Using br As New BinaryReader(fs)

            Dim bytes As Byte() = br.ReadBytes(DirectCast(fs.Length, Long))

            Dim constr As String = ConfigurationManager.ConnectionStrings("constr").ConnectionString

            Using con As New SqlConnection(constr)

                Dim query As String = "insert into tblFiles values (@Name, @ContentType, @Data)"

                Using cmd As New SqlCommand(query)

                    cmd.Connection = con

                    cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = filename

                    cmd.Parameters.Add("@ContentType", SqlDbType.VarChar).Value = contentType

                    cmd.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes

                    con.Open()

                    cmd.ExecuteNonQuery()

                    con.Close()

                End Using

            End Using

        End Using

    End Using

    Response.Redirect(Request.Url.AbsoluteUri)

End Sub
This is mysql database (same that the example..)
Name:  database.jpg
Views: 5949
Size:  9.2 KB
My Questions is:
1. for any type of files, it's the correct table type (varbinary)?
2. I try with blob type, but only upload a .bin file..


Thanks a lot for your help!
Best Regards,