Blob field problems

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
HelgeLange
Posts: 17
Joined: Wed 13 Jun 2007 16:40
Location: Caracas

Blob field problems

Post by HelgeLange » Wed 13 Jun 2007 16:56

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 ?

HelgeLange
Posts: 17
Joined: Wed 13 Jun 2007 16:40
Location: Caracas

Post by HelgeLange » Wed 13 Jun 2007 19:11

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.

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Thu 14 Jun 2007 06:42

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;

HelgeLange
Posts: 17
Joined: Wed 13 Jun 2007 16:40
Location: Caracas

Post by HelgeLange » Thu 14 Jun 2007 14:36

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 :)

Jackson
Posts: 512
Joined: Thu 26 Jan 2006 10:06

Post by Jackson » Fri 15 Jun 2007 13:07

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.

Post Reply