Page 1 of 1

Blob field problems

Posted: Wed 13 Jun 2007 16:56
by HelgeLange
Hi,
I'm just evaluating SDAC in order to switch from the current components we're using to SDAC.
The speed is really good, but we still have problems with the usage of blobfields.

The definition in the database is "text" and I tried all kind of solutions, I could find here in the forum. Mostly I get the Error, that the statement couldn't be prepared, sql_variant is incompatible with text...

The SQL statement looks like this

Code: Select all

'UPDATE Generic_Templates SET Template_Data=:Template_Data WHERE TemplateID=:TemplateID';
Template_Data is the blobfield, the data for the blob come with a TMemoryStream.

The code to set the blob parameter for the query looks like :

Code: Select all

    Query.ParamByName('Template_Data').ParamType := ptInput;
    Query.ParamByName('Template_Data').LoadFromStream(aStream, ftMemo);
Any Ideas, what I'm doing wrong ?

Posted: Wed 13 Jun 2007 19:11
by HelgeLange
Oh, I should add, that I create TMSQuery on-the-fly inside a component of mine.

So I actually set the SQL, call Prepare and set the parameters.

Posted: Thu 14 Jun 2007 06:42
by Antaeus
You should assign ParamType and DataType for the each parameter in your query before preparing. This may look like this:

Code: Select all

  Query.ParamByName('TemplateID').ParamType := ptInput;
  Query.ParamByName('TemplateID').DataType := ftInteger;
  Query.ParamByName('Template_Data').ParamType := ptInput;
  Query.ParamByName('Template_Data').DataType := ftMemo;
  Query.Prepare;

Posted: Thu 14 Jun 2007 14:36
by HelgeLange
ok thanks, that works just fine.
But there isn't an automatic way to let the component do it ? It works obviously, if you use the component on a form. It's not that big deal to set it up as you proposed, since I have just like 20 queries to do in this component. But nevertheless, just out of curiousity I'd like to know :)

btw... I'm impressed about the speed advantage we have with your components, the order went already to our managment :)

Posted: Fri 15 Jun 2007 13:07
by Jackson
You should specify the ParamType and DataType for all parameters in the query only if you use the Prepare method. That is why it works in design time. Do not use the Prepare method if you can.