🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.interbase.thirdparty
3 messages
3 total messages Started by Jack Mason Fri, 26 Jan 2007 16:38
Using TIBQuery for Update
#177
Author: Jack Mason
Date: Fri, 26 Jan 2007 16:38
39 lines
1772 bytes
We have the following code:

...

var Stock_Location: string;
...

procedure TMainForm.TestQueryBeforePost(DataSet: TDataSet);
begin
   DataSet.FieldByName('LOCATION').AsString := Stock_Location;
end;

procedure TMainForm.SetLocation;
begin
...

Stock_Location := '33';
TestQuery.Close;
TestQuery.SQL.Text := 'SELECT * FROM STOCK WHERE STOCKNO=''' + 
                                    StockNo_Str + '''';
TestQuery.Open;
if not TestQuery.IsEmpty then
        begin
          TestQuery.Edit;
          TestQuery.Post;
        end
       else
        begin
          TestQuery.Append;
          TestQuery.Post;
        end;
..
end;

TestQuery.ReadOnly is set to False, TestQuery.Unidirectional is set to 
False, yet when the TestQuery.Edit or TestQuery.Append executes, there 
is an error message saying "Cannot modify a read-only dataset".

What are we doing wrong?
Re: Using TIBQuery for Update
#178
Author: Jeff Overcash (TeamB)
Date: Sun, 28 Jan 2007 06:33
53 lines
2682 bytes
Jack Mason wrote:
> We have the following code:
> 
> ...
> 
> var Stock_Location: string;
> ...
> 
> procedure TMainForm.TestQueryBeforePost(DataSet: TDataSet);
> begin
>   DataSet.FieldByName('LOCATION').AsString := Stock_Location;
> end;
> 
> procedure TMainForm.SetLocation;
> begin
> ...
> 
> Stock_Location := '33';
> TestQuery.Close;
> TestQuery.SQL.Text := 'SELECT * FROM STOCK WHERE STOCKNO=''' + 
>                                    StockNo_Str + '''';
> TestQuery.Open;
> if not TestQuery.IsEmpty then
>        begin
>          TestQuery.Edit;
>          TestQuery.Post;
>        end
>       else
>        begin
>          TestQuery.Append;
>          TestQuery.Post;
>        end;
> ..
> end;
> 
> TestQuery.ReadOnly is set to False, TestQuery.Unidirectional is set to 
> False, yet when the TestQuery.Edit or TestQuery.Append executes, there 
> is an error message saying "Cannot modify a read-only dataset".
> 
> What are we doing wrong?

You have to add an IBUpdateSQL component, link the two and set the update SQL to 
make IBQuery read/write.

-- 
Jeff Overcash (TeamB)
       (Please do not email me directly unless  asked. Thank You)
A human being should be able to change a diaper, plan an invasion, butcher
a hog, conn a ship, design a building, write a sonnet, balance accounts, build
a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act
alone, solve equations, analyze a new problem, pitch manure, program a computer,
cook a tasty meal, fight efficiently, die gallantly.  Specialization is for 
insects.   (RAH)
Re: Using TIBQuery for Update
#182
Author: Jack Mason
Date: Thu, 01 Feb 2007 01:56
1 lines
968 bytes
Thanks, Jeff.
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads