Thema: Delphi Save record to BLOB

Einzelnen Beitrag anzeigen

Medium

Registriert seit: 23. Jan 2008
3.679 Beiträge
 
Delphi 2007 Enterprise
 
#2

Re: Record > BLOB > DB is english problem?

  Alt 5. Dez 2009, 02:03
Line 60: I am not entirely sure about it, but this could be an issue. SizeOf(Monitoring) should be SizeOf(TMonitoring). I've got no Delphi at hand and cannot verify whether SizeOf() on a variable returns the size of it's type, or the size of the pointer to the structure. The latter would be what I belive can be the problem here.
You have it with the type in your loading procedure, but since the whole stream is only as short as the pointer, the data formerly stored in memory is not overwritten. This would be why you can access it when not closing the program in between - after restarting it, adresses usually change, and you didn't create the structure in the first place anyway then.

To make sure you actually write the data rather than a pointer, just check the stream's size after writing it. If it's only 4 bytes, you've only got the pointer.

It may just as well also be, that TMonitoring consists of cascading complex types itself. I think fixed-size arrays are actually written properly, but I am unsure if that is the case for the cascade of structures inside the array. Thus it may also be, that you just save the two 4 byte pointers inside the array that point to the rest. But I am not a 100% on whether Delphi does resolve records/arrays in records/arrays as it automatically does with the first-level record.

I defenitely need to do some more Delphi... I already start forgetting some details
"When one person suffers from a delusion, it is called insanity. When a million people suffer from a delusion, it is called religion." (Richard Dawkins)
  Mit Zitat antworten Zitat