Can anyone offer me a brief segment of code to store a Buffer of 1234 bytes of binary data into a blob field? I have tried the approaches listed below without success. I am using the TSQLite3DataSet component included with Lazarus 9.27 (think it is from the SQLitePass package, might be labeled sqlitelaz0.4 in the packages)
Thanks so much for your help! Victor
____________________________
My failed attempts are listed below as an example:
{For what it is worth, SQLiteBlobField is defined as a TStringField by the compiler when I add fields using the field editor on the form. Don't know if this makes a difference. In fact, most or all of the fields appear to be defined as TStringField...}
Able to modify regular fields e.g.
SQLiteName.AsString := 'ABCD'; { works fine }
However, when trying to write a blob field, I can't get it to work:
Stream := SQLite.CreateBlobStream (SQLiteBlobField, bmWrite);
nBytes := Stream.Write (Buffer^, 1234); { nBytes returns 1234 }
Stream.Free; { nothing is written to the blob field in the file }
Stream := SQLite.CreateBlobStream (SQLiteBlobField, bmREAD);
nBytes := Stream.Read (Buffer^, 1234); { nbytes returns ZERO, nothing is there }
Stream.Free;
Strangely, I tried this approach:
SetLength (LocalStr, 1234);
Move (Buffer^, LocalStr[1], 1234);
SQLiteBlobField.AsString := LocalStr; { does not store anything, although ... }
{ note that my buffer does NOT contain actual "string" data, but rather lots
of binary data, including bytes = 0 }
SQLiteBlobField.AsString := 'ABCD'; { surprisingly, works fine }