Re: Storing Images In A Table
load picture using ADO this works for both MSSQL and MySQL
rsPatron is the recordset, PatronPicture is the field
Databse definition for the field for MySQL then MSSQL is:
PatronPicture MEDIUMBLOB
PatronPicture IMAGE NULL
Loading the picture on my form using an image control:
Set imgPatronPicture.DataSource = rsPatron
imgPatronPicture.DataField = "PatronPicture"
' update the picture to database
'the commondialog1.filename is the loacation of the picture
Dim RS As New ADODB.Recordset
RS.CursorLocation = adUseClient
SQLQuery = "Select Id, patronfile_name, patronfile_size, patronpicture from Patrondata where Id = '" & frmLogon.PWhereIdn & "'"
RS.Open SQLQuery, frmLogon.cnConnection, adOpenStatic, adLockOptimistic
Dim mystream As New ADODB.Stream
mystream.Type = adTypeBinary
mystream.Open
mystream.LoadFromFile CommonDialog1.FileName
'Once we have a file loaded into the stream, we can populate the recordset
'and update it back to MySQL:
RS!patronfile_name = CommonDialog1.FileName
RS!patronfile_size = mystream.Size
RS!Patronpicture = mystream.Read
RS.Update
RS.Close
mystream.Close
'set the picture in image control!
Set imgPatronPicture = LoadPicture(CommonDialog1.FileName)
Subject
Written By
Posted
February 11, 2005 07:47PM
Re: Storing Images In A Table
February 12, 2005 07:09AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.