Is there a way of resetting an ADO field such that the .GetChunk method starts at the beginning of the binary object rather than from where the last GetChunk finished without moving to another record?
Thanks Cclint - I really should have read the documentation in more detail (sorry) and I can see that should work.
HOWEVER, in order to do that, I need another field in the same recordset that would 'support' the GetChunk method and I don't have any others with the adFldLong attribute set.
Thanks for the further suggestion CCLINT. I am going round in circles and, at the moment it does not even seem to reset when I leave the record and return to it. I must be missing something! I will explore further.
Well, a MoveNext/MovePrevious should reset it in any case, as you've mentioned.
Are you resetting the variable which holds the data returned by GetChunk?
I do accept that common sense and Microsoft documentation suggest that pointer should get reset on MoveNext/MovePrevious but the code below (which fires on a move in the recordset) fails when returning to a record that has already passed through this code once successfully. I am navigating using a datagrid and when I first click on a record with a non-null BLOB, all is OK and code runs through. I can then click on lots of other records with null BLOBs OK (no GetChunk Required) but when I return to the original record, I get 'Invalid use of Null' on the GetChunk line unless I re-instate the commented line that does a GetChunk on a dummy BLOB field (created purely for this purpose!) within the same record. I hope I'm missing something really obvious!
Private Sub rsMain_MoveComplete(ByVal adReason As ADODB.EventReasonEnum, ByVal pError As ADODB.Error, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
MsgBox "Move to bookmark " & rsMain.Bookmark & " complete"
Dim StrBlob As String, BlkSize As Long, BlobSize As Long
BlkSize = 16384
'Debug.Print IsNull(rsMain!UdrGridDummy.GetChunk(1))
If Not IsNull(rsMain!UdrGridLayout) Then
Do While BlobSize < rsMain!UdrGridLayout.ActualSize
StrBlob = rsMain!UdrGridLayout.GetChunk(BlkSize)
BlobSize = BlobSize + BlkSize
Loop
End If
I should have said - this code has been trimmed down for the purposes of clarity and narrowing down the problem. Previously it was writing the StrBlob variable to a file.
Well, I wish you would have said that at first (Using a Grid)
Because you are using a DataGrid, when you click on a record in the grid, it will retreive all the data for the record (all that is possible)
As you know, a repeated call with GetChunk when all the data has all ready been retrieved produces NULL. And this is what you are doing because the grid has already used it.
You can see this if you do not move to a different record by clicking on the grid, but do so by just calling the MoveNext/MovePrevious. Then the GetChunk works - of course.
You should be adding a vbNullString to the data when assigning it to a string variable anyways:
The Datagrid does not have a column for this field though it is bound to a recordset which does. Are you saying that the DataGrid (whether it has a column for the BLOB or not) does implicit GetChunks of its own to get all the data? Surely this would suggest that my code would fail EVERY time and not just when I return to the record for the second time?
Yes I have got the GetChunk to work in simpler code and can accept that the DataGrid could be playing a part (sorry I failed to mention it) but I remain confused.
What does the vbnullstring achieve? I thout the getchunk would just return a full buffer or one that is the size of the remaining data, whichever is the smaller?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.