V4MD: SetMedia() not working as expected

Andrew Sinning andrew at learningware.com
Mon Feb 16 10:55:53 CST 2004


Recent posts from me have been raving about the size and speed
efficiencies of BLOB data, but it now appears that I have been duped by
my own programming error.

I was trying to save the contents of a vList member to a BLOB.  It turns
out that I don't understand the basic concept of reading and writing
data from a member to a BLOB.

NOTE: For testing purposes, I am now working with castMembers other than
vList members, such as bitmaps and text members.  I'm getting the same
result.

Please help me understand if I am using the correct methods for reading
and writing.

Here is how I WRITE the data to the db:

  -- get the record
  sql = "SELECT * FROM questionVList WHERE qId = "&qId
  theCursor = new(xtra "VCursor", GetRef(dbConn), sql, kClient,
kReadWrite, kForwardOnly)
  -- update/add the record
  if GetRecordCount(theCursor) = 0 then -- new question
    -- note that when creating a new record, I don't try to add the BLOB
data, yet
    AddRecord(theCursor,[#qId:qId])
  end if
  -- put the BLOB data into field "vList"
 -- vListMem is a member.  I have tried various member types: #vList,
#bitmap, #text
  SetMedia (theCursor, "vList", vListMem)
  SetBlank(theCursor)

This actually SEEMs to be working.  The database grows in size
incrementally each time I execute.


Here is how I READ the data from the db:  This is where the problem
seems to be.

  sql = "SELECT * FROM questionVList WHERE qId = "&qId
  theCursor = new(xtra "VCursor", GetRef(dbConn), sql, kClient,
kReadOnly, kForwardOnly)
  if GetRecordCount(theCursor) = 0 then -- question not found
    SetBlank(theCursor)
    theCursor = void
    return 0
  end if
  -- vListMem is a member
  put BLOB_GetDataSize(theCursor, "vList")
  GetMedia(theCursor, "vList", vListMem)
  SetBlank(theCursor)
  theCursor = void

When I execute BLOB_GetDataSize(theCursor, "vList"), the result is
ALWAYS "0", but there has to be something there, why else would the
database be getting bigger?

The result of
  GetMedia(theCursor, "vList", vListMem)
causes NO CHANGE in the member vListMem

Thanks.




More information about the Valentina mailing list