Subject | Re: [ib-support] A first time question... |
---|---|
Author | lists |
Post date | 2002-10-31T08:01:50Z |
> >I can access the jpeg as a memory stream (or a file if that is better),but
> >I dont know the SQL syntax to update the blob fieldHere's some crude but simple code - it's Delphi and IBO - but the principles
>
> All that's needed is for your client application to present a blob as a
> parameter for the blob field in your insert and update statements, e.g.
> create simpletable (
> id integer not null primary key,
> jpeg blob sub_type 0);
>
> commit;
>
> Your dataset SQL should resolve to sthg like this:
> insert into simpletable (id, jpeg)
> values ( :id, :jpeg);
>
should be the same:
procedure TfrmWebEdit.BitBtn2Click(Sender: TObject);
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;
able1.Refresh;
finally
st.Free;
t1.Unprepare;
T1.Free;
end;
end;
Delphi/BCB support list...but as a hint, use stream methods to
> move the image file into the TBlobfield (possibly IBX has its ownDavid Keith
> descendant; IB Objects has a high degree of encapsulation of blobs and
> specialised blobstream classes).
>
> If your components don't automatically assign values to the parameters (
> :id, :jpeg), use the methods of the Params[] array to assign the blob. If
> using the VCL (rather than custom components) use the AsString method to
> pass either a string or a binary stream to a blob parameter. If you root
> around the Delphi help enough, you should find enough examples to work out
> a way to do this. The TJPEGImage topic seems quite well documented.