|
-
Apr 30th, 2000, 09:02 PM
#1
I have been trying to store images in a database for sometime, i can do it directly from Access97 but i can't transfer these image to any control in VB.
What i'm really doing is, i store the images for my toolbar buttons in a database so that the user can edit them and the changes will be kept. So what i need to know, is how do i extract and how do i update images directly from a ole-Object field in an Access 97 Database using DAO 3.5 (or 3.6, i got that one also, but i don't have the help file so i'm using 3.5)
-
May 8th, 2000, 10:09 PM
#2
Addicted Member
-
May 10th, 2000, 08:46 PM
#3
Woohoo thanks
Woohoo, gee thanks, i needed that to get smile on my face. Thanks a lot, i'll try it out...
-
Dec 11th, 2000, 09:04 AM
#4
Lively Member
erm...
Could I have a copy of this code? The link is sending my to a Russion website.
Paul.
Set MCP = NTServer + NTWorkstation
-
Dec 11th, 2000, 09:21 AM
#5
Addicted Member
:)
These messages you found was sent last year and I have now new great site but unfortunately only for russian speaking people Here is the code you request:
Code:
Dim dbTest As Database
Dim rstAlbum As Recordset
Dim FileLen&, X%, lngOffset&, Chunks%, lngTotalSize&
Dim Arr() As Byte
Const ArrSize As Integer = 16384
Sub ReadPictureFromDb()
On Error Resume Next
Open "d:\picture.gif" For Binary Access Write As #1
lngTotalSize = rstAlbum!Picture.FieldSize
Chunks = lngTotalSize \ ArrSize
Fragment = lngTotalSize Mod ArrSize
ReDim Arr(ChunkSize)
Arr() = rstAlbum!Picture.GetChunk(lngOffset, ArrSize)
Put #1, , Arr() lngOffset = lngOffset + ArrSize
With rstAlbum
Do While lngOffset < lngTotalSize
Arr() = !Picture.GetChunk(lngOffset, ArrSize)
Put #1, , Arr()
lngOffset = lngOffset + ArrSize
Loop Close #1
.Close
End With
End Sub
Sub SavePictureToDb()
rstAlbum.AddNew
Open "c:\picture.gif" For Binary Access Read As #1
FileLen = LOF(1) Chunks = FileLen \ ArrSize Fragment = FileLen Mod ArrSize
ReDim Arr(Fragment)
With rstAlbum Get #1, , Arr()
!Picture.AppendChunk Arr()
ReDim Arr(ChunkSize)
For I = 1 To Chunks
Get DataFile, , Arr()
!Picture.AppendChunk Arr()
Next
Close #1 .Update
End With
End Sub
Private Sub Form_Load()
Set dbTest = OpenDatabase("d:\db1.mdb", True)
Set rstAlbum = dbTest.OpenRecordset("select * from Album", dbOpenDynaset)
SavePictureToDb
ReadPictureFromDb
Set rstAlbum = Nothing
dbTest.Close
End Sub
Have a nice day,
Alexei
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|