Click to See Complete Forum and Search --> : Update a picture into Sql Server database.


Phogang
October 2nd, 2001, 03:15 AM
In SQL Server, Northwind database, Categories table has a column "Picture", that column type is image. I think that all picture is update into data by binary type.

But I don't know how to display that data into a real picture in VB form, And I also can't update a picture into database when I choose a picture from my application.
Hope to hear from you soon.

vin
October 2nd, 2001, 05:38 AM
OK, one easy thing you could do is to save this to file using getChunk and then open it with LoadPicture().

here is an example



Dim sTempFile as string
Dim iFileNum as Long
Dim abBytes() as Byte
Dim lFileLength as Long

sTempFile = "c:\mypicture.jpg"

' Open your recordset here
' rs.Open "Select ...",cnn

iFileNum = FreeFile
Open sTempFile for binary as #iFileNum
lFileLength = LenB(rs(FieldName))
abBytes = rs(FieldName).GetChunk(lFileLength)
Put #iFileNum, , abBytes()
Close #iFileNum
PictControl.Picture = LoadPicture(sTempFile)

' close your recordset here





Hope this helps,
I don't know if this is the best way,
there may have another ways, you
may try to explore the databound properties
of picture control, but the above works for sure.



Valery Iskarov Nikolov
Software Dynamics