Public Sub SaveImageFileToDatabase(ByVal imagefilePath As String) ' Define a stream to convert the file into bytes. Dim fs As New FileStream(imagefilePath, FileMode.Open) ' Define an array of bytes with a size equal to the length of image content Dim data() As Byte = New [Byte](fs.Length) {} ' Read the image data into the byte array fs.Read(data, 0, fs.Length) ' Create an sql connection object Dim connection As New System.Data.SqlClient.SqlConnection("data source=(local);initial catalog=MyDatabaseName;user id=John;password=LittleBird") connection.Open() ' Execute the query to save bytes into database table. Dim cmd As SqlCommand = New SqlCommand cmd.Connection = connection cmd.CommandText = "insert imagetable values(@img)" cmd.Parameters.Add(New SqlParameter("@img", SqlDbType.Image)).Value = data cmd.ExecuteNonQuery() connection.Close() End Sub