Hard to say without seeing your code. However,
> many data). I used AppenChunk method to retrieve the picture. The
yes i used GetChunk method
Here is the code
sSQL = "select * from images"
sSQL = "select task1 from t_tasks"
Set rsImage = New ADODB.Recordset
rsImage.CursorType = adOpenDynamic
rsImage.LockType = adLockOptimistic
rsImage.Open sSQL, objDB
If rsImage.BOF Then
MsgBox ("No records in Database")
cmdnext.Enabled = False
txtName.SetFocus
Exit Sub
End If
'''txtName.Text = rsImage("name")
'''txtdesig.Text = rsImage("Designation")
'''txttitle.Text = rsImage("Title")
''' txtpno.Text = rsImage("Phoneno")
If Not rsImage.EOF Then
nHandle = FreeFile
sPath = App.Path
sFile = sPath & "\output.bin"
Open sFile For Binary Access Write As nHandle
Set fld = rsImage("task1")
lsize = rsImage("task1").ActualSize
iChunks = lsize \ conChunkSize
nFragmentOffset = lsize Mod conChunkSize
varChunk() = rsImage("task1").GetChunk(nFragmentOffset)
Put nHandle, , varChunk()
lOffset = nFragmentOffset
For i = 1 To iChunks
ReDim varChunk(conChunkSize) As Byte
varChunk() = rsImage("task1").GetChunk(conChunkSize)
Put nHandle, , varChunk()
DoEvents
Next
End If
Close nHandle
Set Picture1.Picture = LoadPicture(sFile, , vbLPColor)
Any ideas?
Madhivanan
Norm Cook - 26 May 2005 16:51 GMT
Perhaps someone with more ADO experience can spot an error.
Personally, I use DAO and set the field type to Memo vice OLE Object.
Saving & retrieving pics if fairly straightforward with this method
Private Sub SavePic(ByVal FileName As String)
Dim filenum As Integer
Dim rst As Recordset
Dim str As String
'read the file into a string
filenum = FreeFile
Open FileName For Binary As #filenum
str = Space$(LOF(filenum))
Get #filenum, , str
Close #filenum
'add it to the DB table
Set rst = db.OpenRecordset("Table1")
rst.AddNew
rst("Data") = str
rst.Update
rst.Close
Set rst = Nothing
End Sub
Private Sub LoadPic()
Dim Dat As String
Dim rst As Recordset
Dim filenum As Integer
'read the DB pic data
Set rst = db.OpenRecordset("Table1")
rst.MoveFirst 'gets the 1st picture
Dat = rst.Fields("Data")
'write it out to a file
Open App.Path & "\work.jpg" For Binary As 1 'change ext as approp
Put #1, , Dat
Close 1
Picture1.Picture = LoadPicture(App.Path & "\work.jpg")
Kill App.Path & "\work.jpg"
Set rst = Nothing
End Sub
> yes i used GetChunk method
>
[quoted text clipped - 48 lines]
>
> Madhivanan