Subject | Re: [IBO] IB_Query1 is not storing Data in the Database |
---|---|
Author | Aage Johansen |
Post date | 2004-08-05T18:56:35Z |
Tarak Patel wrote:
You say "try to insert", but you use Open/Append/Post! Do get rid of the
TTable terminology.
Try somehing like:
TForm1.BtnClick(Sender: TObject);
begin
with IB_DSQL1 do // For INSERT, use TIB_DSQL
begin
SQL.Clear;
SQL.Add('insert into YOURTABLE (TID,Name) values (:TID,:Nam)');
Prepare;
ParamByName('TID').AsInteger:=StrToInt(Edit1.Text );
ParamByName('Nam').AsString:=Edit2.Text;
ExecSQL;
end;
end;
Don't forget to commit the transaction if you want the database to retain
the new record.
It's just otTomH (so it may contain errors), but you should get the
idea. The code can easily be optimized.
--
Aage J.
> First Stepin grid when i do try to insert through text box.....
> ...
> Second Step
> -------------------
> procedure TForm1.BtnClick(Sender: TObject);
> begin
> IB_Query1.Close;
> IB_Query1.Open;
> IB_Query1.Append;
> IB_Query1.FieldByName('TID').AsInteger := StrToInt(Edit1.Text );
> IB_Query1.FieldByName('Name').AsString := Edit2.Text ;
> IB_Query1.Post;
>
> Edit1.Text := '';
> Edit2.Text := '';
> end;
> ---------------------------
>
> This Code is not storing Data into my database,but it shows live update
You say "try to insert", but you use Open/Append/Post! Do get rid of the
TTable terminology.
Try somehing like:
TForm1.BtnClick(Sender: TObject);
begin
with IB_DSQL1 do // For INSERT, use TIB_DSQL
begin
SQL.Clear;
SQL.Add('insert into YOURTABLE (TID,Name) values (:TID,:Nam)');
Prepare;
ParamByName('TID').AsInteger:=StrToInt(Edit1.Text );
ParamByName('Nam').AsString:=Edit2.Text;
ExecSQL;
end;
end;
Don't forget to commit the transaction if you want the database to retain
the new record.
It's just otTomH (so it may contain errors), but you should get the
idea. The code can easily be optimized.
--
Aage J.