Depannage

BLAISE - 13 nov. 2014 à 10:19
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 - 13 nov. 2014 à 11:21
Bonjour,

Aidez moi svp mes amis. Comment afficher une image provenant dans un champ du type OLE de la base de données acces sur un objet VB6 ?

2 réponses

ucfoutu Messages postés 18038 Date d'inscription lundi 7 décembre 2009 Statut Modérateur Dernière intervention 11 avril 2018 211
13 nov. 2014 à 10:49
Bonjour,
peux-tu reformuler de manière plus claire, s'il te plait.

0
jordane45 Messages postés 38144 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 21 avril 2024 344
13 nov. 2014 à 11:21
Bonjour,

BLOB - Retieve image stored in database
http://bytes.com/topic/visual-basic/insights/641546-blob-retrieve-image-stored-database

 Dim CN As New ADODB.Connection
Dim RS As ADODB.Recordset
Dim DataFile As Integer, Fl As Long, Chunks As Integer
Dim Fragment As Integer, Chunk() As Byte, i As Integer, FileName As String
 
Private Const ChunkSize As Integer = 16384
Private Const conChunkSize = 100
 
Private Sub Form_Load()
    CN.Open "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=Pubs;Data Source=Test"
    Dim strsql As String
 
    strsql = "SELECT * FROM pub_info where pub_id = '9999'"
    RS.Open strsql, CN, adOpenForwardOnly, adLockReadOnly
      ShowPic
    Set RS = Nothing
    Set RS = New Recordset
End Sub
 
Private Sub ShowPic()
    DataFile = 1
    Open "pictemp" For Binary Access Write As DataFile
        Fl = RS!logo.ActualSize ' Length of data in file
        If Fl = 0 Then Close DataFile: Exit Sub
        Chunks = Fl \ ChunkSize
        Fragment = Fl Mod ChunkSize
        ReDim Chunk(Fragment)
        Chunk() = RS!logo.GetChunk(Fragment)
        Put DataFile, , Chunk()
        For i = 1 To Chunks
            ReDim Buffer(ChunkSize)
            Chunk() = RS!logo.GetChunk(ChunkSize)
            Put DataFile, , Chunk()
        Next i
    Close DataFile
    FileName = "pictemp"
    Picture1.Picture = LoadPicture(FileName)
End Sub


0
Rejoignez-nous