Problem to store image in SQL server 6.0 with VB 4 
Author Message
 Problem to store image in SQL server 6.0 with VB 4
Hi
I have problem to store image in SQL server, I have
tried with both RDO and DAO, of course getchunk, with
and without stored procedures. Anyone who have done
this and can send me some example.

Im using SQL server 6.0, VB 4/32 bit and NT 3.51

Thanks Mats.



Tue, 01 Sep 1998 03:00:00 GMT  
 Problem to store image in SQL server 6.0 with VB 4
I too have had the same problem as you, but I have figured out that a byte
array will work quite well.

Example:

Sub StoreImage()

    dim bytImage() as byte
    dim lTotalSize as long
    dim sImageFileName as string
    dim rs as rdoResultset

    sImageFileName = "C:\Windows\256clr.bmp"

    Open sTempFileName For Binary Access Read As #1
        lTotalSize = Lof(sTempFileName)
        bytImage = InputB(lTotalSize, #1)
    Close #1

    'This code assumes you have a connection and resulset already
    With rs
        .AddNew
        !Index_ID = 1
        !BLOB_Field.AppendChunk = bytImage
        .Update
    End With

End Sub

To retrieve the image:

Public Sub RetrieveImages()

    Dim bytImage() As Byte
    Dim sTempFileName As String

    bytImage = rs!BLOB_Field.GetChunk(THIS IS THE SIZE OF THE IMAGE)

    'Get a unique, temporary filename
    sTempFileName = "C:\temp.bmp"

    'Copy the binary array to the temp filename
    Open sTempFileName For Binary Access Write As #1
    Put #1, , bytImage
    Close

    picImage.Picture = LoadPicture(sTempFileName)

    Kill sTempFileName

End Sub

I hope this helps, I think that RDO is the way to go, DAO seems to kludgy
to me.

Regards,

Jason Carpenter



Wed, 02 Sep 1998 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Store and retrieve image on SQL server 7.0 using VB 6.0

2. VB 6.0, SQL Server 7.0 and Images

3. Store the image in picture box control into the image data type in SQL server

4. Storing Images in Sql Server & V.B

5. Storing Images in Sql Server & V.B

6. Storing Images in Sql Server & V.B

7. Storing Images in Sql Server & V.B

8. Storing Images in Sql Server & V.B

9. Storing Images in Sql Server & V.B

10. VB4 RDO Won't detect an error in an SQL Server 6.0 stored procedure

11. executing stored procedures from VB3.0/SQL Server 6.0

12. MS SQL Server 6.0 stored procedures

 

 
Powered by phpBB® Forum Software