'Delphi how to save #temptable data into another table with dataset/dataSetProvider/ADOQuery?
My code is like:
with ArrangementClientDataSet do
begin
close;
dataset.commandText := 'exec getArrangementData';
open;
edit;
end;
In procedure the code is like
select cyear,ccode from #arrangement
So when I click query button the dbgrid shows the data.
And now I want to add a save button so that when I click, the data can be saved into another table 'arrangement'.
The code on Save button is:
procedure SaveToolButtonClick(Sender:TObject);
begin
with ArrangementClientDataSet do
begin
first;
ApplyUpdates(0);
end;
end;
I tried to set
procedure DataSetProviderGetTableName(Sender:TObject;DataSet:TDataSet;var TableName :String);
begin
TableName := 'arrangement';
end;
procedure ADOQueryAfterOpen(DataSet:TDataSet);
begin
with ArrangementADOQuery do
begin
fieldByName('cyear').providerFlags := [pfInUpdate,pfInKey];
end;
end;
But it doesn't work, SQL Server Profiler can't catch the insert SQL.
If I change a value in dbgrid and then click the save button SQL Server Profiler can catch a update SQL like
update arrangement set ccode='1' where pfInKeyField = '2022'
But it's not right because data is not yet contained in table
So what should I do?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
