3

I am searching at the moment for a possibility in Advantage Database Server via sql to put a byte stream, so called blob file into a table. When I build up a complete database I am doing it like this:

TBlobField(BaseTable.FieldByName('BlobData')).LoadFromStream(BinaryStream);

Now I would like to add an Entry into my database where one Field has the 'BlobData'. I started like that:

FADSQuery.SQL.Add('Insert Into '+DBName'+'(BlobData)');
TBlobField(FADSQuery.ParamByName('BlobData')).LoadFromStream(BinaryStream);

But the compiler tells me it cannot find the BlobData field.:( Is it nearly right to do it like that? I wouldn't like to put inside the insert into statement a whole file by filename.

Thank you in advance

3
  • 2
    "advanced database server" or "Advantage Database Server" ? Commented Jan 24, 2012 at 11:52
  • 3
    "But the compiler tells me it cannot find the BlobData". Please don't "translate" error messages for us. Always provide the exact error message you're receiving. Even if the error message doesn't tell you much, it might tell allot to someone else. Commented Jan 24, 2012 at 11:57
  • So, it is the Advantage Database Server. Commented Jan 24, 2012 at 12:48

1 Answer 1

15

Try something like that:

FADSQuery.SQL.Add('Insert Into '+DBName+'(BlobData) values (:BlobData)');
FADSQuery.ParamByName('BlobData').LoadFromStream(BinaryStream, ftBlob); 
Sign up to request clarification or add additional context in comments.

4 Comments

+1 for suggesting a syntax for the named parameter and for spotting the wrongly cast to TBlobField.
Thank you very much for that fast answer. It helped me a lot. And works by including the blobtype : FADSQuery.ParamByName('BlobData').LoadFromStream(BinaryStream,ftBlob);
@AndréDziurla: if it solves the problem, would be nice to mark this answer as "Accepted".
+1. I'd suggest just using FADSQuery.SQL.Text instead, though, since the INSERT is probably the only statement and you won't have to worry about clearing the previous SQL first.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.