Subject Re: [IBO] TIBOQuery posting error
Author Nols Smit
Notice also the use of Assign to move the streamed image into the blob
parameter. There are some effective ways to work with blob in the native
IBO row type - look at TIB_ColumnBlob.

I can't find sucg a component.


Nols Smit
----- Original Message -----
From: Helen Borrie
To: IBObjects@yahoogroups.com
Sent: 06 July, 2005 12:22 AM
Subject: Re: [IBO] TIBOQuery posting error


At 10:58 PM 5/07/2005 +0200, you wrote:
>I'm using the code appearing below to update a FireBird table via an
>IntraWeb application:
>
> if UserSession.IBOPhotoAlbum.State = dsInsert then
> begin
> with UserSession.IBOPhotoAlbum do
> begin
> Close;
> SQL.Clear;
> SQL.Add('Insert into PhotoAlbum (Description, LoadedPhoto)');
> SQL.Add('Values (:Description, :LoadedPhoto)');
> ParamByName('Description').AsString := edtDescription.text;
> ParamByName('LoadedPhoto').LoadFromStream (UserSession.ms,
> ftGraphic);
> Open;
> end;
> end;
>
>But on executing the Open statement, I get the following error message
>although the record is loaded.
>
>class EIB_Error with message 'FieldNo: -1 not found'.
>
>The table has a unique key named ID. I increment this key via the
>following trigger code:
>
>AS
>BEGIN
> IF (NEW.ID is null) THEN
> NEW.ID = GEN_ID(photoalbum_id_gen, 1);
>END
>
>Apart from the error message, the updating seems fine.

Don't call Open and Close on an executable query - call ExecSQL.. Open and
Close are for datasets (SELECT statements).

More tips:

Use a TIB_DSQL for this statement. It carries none of the superfluous
overhead that you are getting in the iboquery. You can hook it up to your
TIBODatabase, using its IB_Connection property.

Don't clear and reassign the SQL if the operation is going to be executing
the same statement every time. Assign the SQL statically in the IDE, or
just once the first time you execute the statement. All you need to do
each time then is just assign the values to the params.

For an executable DML statement like this, it won't do any harm to test
that the statement is prepared, before you assign values to the params:

with YourStatementObject do
begin
...
if not Prepared then Prepare;
ParamByName('Description').AsString := edtDescription.text;
ParamByName('LoadedPhoto').Assign (YourImageStream);
Execute;
end;

Notice also the use of Assign to move the streamed image into the blob
parameter. There are some effective ways to work with blob in the native
IBO row type - look at TIB_ColumnBlob.

Helen




___________________________________________________________________________
IB Objects - direct, complete, custom connectivity to Firebird or InterBase
without the need for BDE, ODBC or any other layer.
___________________________________________________________________________
http://www.ibobjects.com - your IBO community resource for Tech Info papers,
keyword-searchable FAQ, community code contributions and more !



SPONSORED LINKS Database design software Database software Membership database software
Database management software Resume database software Database development software


------------------------------------------------------------------------------
YAHOO! GROUPS LINKS

a.. Visit your group "IBObjects" on the web.

b.. To unsubscribe from this group, send an email to:
IBObjects-unsubscribe@yahoogroups.com

c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


------------------------------------------------------------------------------



[Non-text portions of this message have been removed]