1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| Private Sub ValiderImage(ByVal CheminImage As String)
If CheminImage = "" Then Exit Sub
SqlConn.Open()
Dim myCommand As New SqlCommand
myCommand.Connection = SqlConn
myCommand.CommandText = "update zz_societe set Logo=@BLOBData where (Code=@Idx)"
myCommand.Parameters.Add(New SqlParameter("@Idx", ancien_code.Value))
'Dim strBLOBFilePath As String = CheminImage
Dim fsBLOBFile As New FileStream(CheminImage, FileMode.Open, FileAccess.Read)
Dim bytBLOBData(fsBLOBFile.Length() - 1) As Byte
fsBLOBFile.Read(bytBLOBData, 0, bytBLOBData.Length)
fsBLOBFile.Close()
myCommand.Parameters.Add(New SqlParameter("@BLOBData", SqlDbType.VarBinary, bytBLOBData.Length, ParameterDirection.Input, False, 0, 0, Nothing, DataRowVersion.Current, bytBLOBData))
myCommand.ExecuteNonQuery()
SqlConn.Close()
myCommand = Nothing
bytBLOBData = Nothing
fsBLOBFile = Nothing
End Sub |
Partager