Board index » delphi » Query problem

Query problem

Query.AppendRecord([nil, Na.Text, ZR.Text, Mj.Text, Sv.Text, Pl.Text,
Mn.Text, StrTocurr(Iz.Text), StrToDate(Da.Text)]);

I put nil because the first field is autoinc type field, but bde raises an
exception:
"Field value required. Field: ID". If I put some value it also raises an
exception:
"Cannot change field ID". It is doing fine with TTable:

Table.AppendRecord([nil, Na.Text, ZR.Text, Mj.Text, Sv.Text, Pl.Text,
Mn.Text, StrTocurr(Iz.Text), StrToDate(Da.Text)]);

BUT, Grid is connected to query so changes aren't displayed until I restart
the program (close it and then run again). Anyone know the solution? Thanks
in advance!

 

Re:Query problem


On what you are working?
If it is some database server, then you need stored procedure.
If it is some desktop database like Pdox or similar, I would suggest
you to use TTable for editing and updating as they have proven much
better in those operations than TQuery (when you have autoinc field).

Do not forget to make your "triggers" on beforeInsert, post etc...

On Mon, 4 Dec 2000 16:01:48 +0100, "Dzenan Zukic" <zzm...@hotmail.com>
wrote:

Quote
>Query.AppendRecord([nil, Na.Text, ZR.Text, Mj.Text, Sv.Text, Pl.Text,
>Mn.Text, StrTocurr(Iz.Text), StrToDate(Da.Text)]);

>I put nil because the first field is autoinc type field, but bde raises an
>exception:
>"Field value required. Field: ID". If I put some value it also raises an
>exception:
>"Cannot change field ID". It is doing fine with TTable:

>Table.AppendRecord([nil, Na.Text, ZR.Text, Mj.Text, Sv.Text, Pl.Text,
>Mn.Text, StrTocurr(Iz.Text), StrToDate(Da.Text)]);

>BUT, Grid is connected to query so changes aren't displayed until I restart
>the program (close it and then run again). Anyone know the solution? Thanks
>in advance!

Re:Query problem


In the Table.afterpost event you can do something like this:

procedure TDataModule.MainlTableAfterPost(DataSet: TDataSet);
begin
  DbiSaveChanges(MainTotalTable.Handle)
end;

This takes care of direct writing to your db_file. instead of placing things
in the buffer of the BDE.

Quote
"Beli" <b...@SPAAMMgreenhousemm.com> wrote in message

news:3a2d77f5.100208131@news.terra.com.br...
Quote
> On what you are working?
> If it is some database server, then you need stored procedure.
> If it is some desktop database like Pdox or similar, I would suggest
> you to use TTable for editing and updating as they have proven much
> better in those operations than TQuery (when you have autoinc field).

> Do not forget to make your "triggers" on beforeInsert, post etc...

> On Mon, 4 Dec 2000 16:01:48 +0100, "Dzenan Zukic" <zzm...@hotmail.com>
> wrote:

> >Query.AppendRecord([nil, Na.Text, ZR.Text, Mj.Text, Sv.Text, Pl.Text,
> >Mn.Text, StrTocurr(Iz.Text), StrToDate(Da.Text)]);

> >I put nil because the first field is autoinc type field, but bde raises
an
> >exception:
> >"Field value required. Field: ID". If I put some value it also raises an
> >exception:
> >"Cannot change field ID". It is doing fine with TTable:

> >Table.AppendRecord([nil, Na.Text, ZR.Text, Mj.Text, Sv.Text, Pl.Text,
> >Mn.Text, StrTocurr(Iz.Text), StrToDate(Da.Text)]);

> >BUT, Grid is connected to query so changes aren't displayed until I
restart
> >the program (close it and then run again). Anyone know the solution?
Thanks
> >in advance!

Other Threads