|Subject||Re: [IBO] TIBOQuery posting error|
> I'm using the code appearing below to update a FireBird tableI've never used IntraWeb so please excuse me if my comments are
> via an IntraWeb application:
out of place...
> if UserSession.IBOPhotoAlbum.State = dsInsert thenThis line seems strange...
if IBOPhotoAlbum is a dataset (can be in dsInsert) then why
would you want to check it was insert state when you are
about to close it anyway?
if IBOPhotoAlbum is a dataset then...
> begin...should not have its SQL set to a non-query statement.
> with UserSession.IBOPhotoAlbum do
> SQL.Add('Insert into PhotoAlbum (Description, LoadedPhoto)');
> SQL.Add('Values (:Description, :LoadedPhoto)');
> ParamByName('Description').AsString := edtDescription.text;
> ParamByName('LoadedPhoto').LoadFromStream (UserSession.ms, ftGraphic);
The statement you have defined to the SQL is an insert and
this will not define any fields - a dataset must define some
fields and return zero or more rows of those fields. An
insert statement does neither.
It seems to me that...
IBOPhotoAlbum is not a dataset, in which case some of the
code above (checking for insert state) does not make sense.
IBOPhotoAlbum is a dataset in which case you will need to
do one of:
- having found IBOPhotoAlbum in insert state, and assuming
it has description and loadedphoto fields then use:
FieldByName('Description').AsString := edtDescription.Text;
without closing or changing the dataset in any other way.
- create a separate IB_DSQL to perform the insert as you
have it above, and then optionally refresh the
IBOPhotoAlbum dataset to pickup the new row.