Subject Re: [IBO] Blob insert woes...
Author Admin
Geoff, All -

Thanks for the support in solving this problem. In the process you've
demonstrated several techniques that are more efficient for getting
things done. Using the snip below, and some custom modifications to fit
the GUI/Process flow, the below listed code is ultimately what worked:

var
st : TStream;
t1 : TIB_DSQL;
s : string;
begin
try
s := '"VERSION"';
t1 := TIB_DSQL.Create(Self);
t1.IB_Connection := ibconn1;
t1.IB_Transaction := ibt1;
t1.SQL.Add('INSERT INTO GRAPHICSTREAM (GRAPHIC, GRAPHICNAME, '+ S +
')');
t1.SQL.Add('VALUES (:GRAPHIC,:GRAPHICNAME,:"VERSION");');
t1.Prepare;
st := t1.CreateBlobStream(t1.ParamByName('GRAPHIC'),bsmWrite);
image.Picture.Graphic.SaveToStream(st);
t1.ParamByName('GRAPHICNAME').asString := extractFileName(edit1.text);
t1.ParamByName('"VERSION"').AsInteger := 1;
t1.Execute;
table1.Refresh;
except
on E:EIB_ISCError do
case E.ERRCODE of

335544665 : begin
messageBeep(0);
messageDlg('You have attempted to '
+'use an existing image '
+'name and version '
+'number. Please choose '
+'a different name for '
+'the image.',mtError,
[mbCancel],0);
st.Free;
t1.Unprepare;
t1.Free;
exit;
end;
end;
end;
st.Free;
t1.Unprepare;
T1.Free;
end;

Thanks again for everything.

David Keith



Geoff Worboys wrote:
>
> So instead of all the complex stuff you are doing by creating TField
> definitions just do something like...
>
> t1 := TIB_DSQL.Create(Self);
> t1.IB_Connection := ibconn1;
> t1.IB_Transaction := ibt1;
> t1.SQL.Add( 'UPDATE GRAPHICSTREAM' );
> t1.SQL.Add( 'SET GRAPHIC=:GRAPHIC' );
> t1.SQL.Add( 'WHERE GRAPHICNAME=:GRAPHICNAME AND' );
> t1.SQL.Add( ' VERSION=:VERSION' );
> t1.Prepare;
> t1.ParamByName( 'GRAPHICNAME' ).AsString :=
> extractFileName(edit1.text);
> t1.ParamByName( 'VERSION' ).AsInteger := 1;
> t1.ParamByName( 'GRAPHIC' ).LoadFromFile(edit1.text);
> t1.Execute;
>

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