Voilà le bout de mon code concerné:
Private Sub ajout_image_Click()
CommonDialog1.ShowOpen
FileCopy CommonDialog1.filename, App.Path & "\tmp.jpg"
Image1.Picture = LoadPicture(App.Path & "\tmp.jpg")
Call requete(Rs, "SELECT image,imsize FROM Films WHERE id=" & identifiant)
With Rs
ObtenirImage App.Path & "\tmp.jpg", Rs .Update End With
Rs.Close
End Sub
Public Sub ObtenirImage(filename As String, rstMain As ADODB.Recordset) ' Pour Obtenir une Image
Dim file_num As String Dim file_length As Long Dim bytes() As Byte Dim num_blocks As Long Dim left_over As Long Dim block_num As Long
file_num = FreeFile ' Prochain Numéro de Fichier Pouvant être Utilisé par l'Instruction Open
Open filename For Binary Access Read As #file_num ' Ouverture du Fichier Temporaire file_length = LOF(file_num) If file_length > 0 Then num_blocks = file_length / BLOCK_SIZE left_over = file_length Mod BLOCK_SIZE
rstMain("imsize") = file_length
ReDim bytes(BLOCK_SIZE) For block_num = 1 To num_blocks Get #file_num, , bytes() rstMain("image").AppendChunk bytes() Next block_num
If left_over > 0 Then ReDim bytes(left_over) Get #file_num, , bytes() rstMain("image").AppendChunk bytes() End If Close #file_num End If
Exit Sub
End Sub
|