Answer the question
In order to leave comments, you need to log in
Why can't I change the data in the database after Sql query?
The client application is written in Delphi using the DevExpress vcl libraries, I connect to the MS SQl server.
I connect to the database in the DataSourse ADoQuery bundle.
Faced this kind of problem:
I change the value of the field:
procedure TForm24.cxButton2Click(Sender: TObject);
begin
DM.tviezdi.edit;
Dm.Tviezdi.FieldByName('Выезд').AsString := 'Да';
DM.Tviezdi.post;
showmessage ('Аварком '+cxDBLookupComboBox3.Text+' назначен')
end;
procedure TForm13.cxButton5Click(Sender: TObject);
begin
dm.Tviezdi.Active := false;
dm.Tviezdi.SQL.clear;
Dm.Tviezdi.SQL.Add('set language Russian set dateformat dmy ');
// Dm.Tviezdi.SQL.Add('select *');
Dm.Tviezdi.SQL.Add('select ');
Dm.Tviezdi.SQL.Add('[dbo].[Дата последнего изменения состояния дела]([dbo].[БД].[№ Заявки]) [Дата последнего изменения состояния дела],');
Dm.Tviezdi.SQL.Add('[dbo].[Просрочка состояния дела]([dbo].[БД].[№ Заявки])[Просрочено],');
Dm.Tviezdi.SQL.Add('[dbo].[БД].[№ Заявки] idLoss,');
Dm.Tviezdi.SQL.Add('*');
Dm.Tviezdi.SQL.Add('FROM [dbo].[БД]');
Dm.Tviezdi.SQL.Add('LEFT JOIN [dbo].[Фото инфо]');
Dm.Tviezdi.SQL.Add('ON [dbo].[Фото инфо].[№ заявки] = [dbo].[БД].[№ Заявки]');
DM.Tviezdi.SQL.Add('WHERE 1=1');
DM.Tviezdi.SQL.Add('-- find');
Dm.Tviezdi.SQL.Add('AND([Дата осмотра] >= '+#39+cxDateEdit1.Text+#39')');
Dm.Tviezdi.SQL.Add('and ([Дата осмотра] <= '+#39+cxDateEdit2.Text+#39')');
Dm.Tviezdi.SQL.Add('Order By [№ Заявки] Desc');
Dm.Tviezdi.ExecSQL;
dm.Tviezdi.Active := true;
end;
Answer the question
In order to leave comments, you need to log in
The problem was solved quite simply .... DM.tviezdi.LockType:= ltBatchOptimistic or ltOptimistic ,
then added a button in the window where Grid is, and added to it: DM.Tviezdi.UpdateBatch(arAll); and everything worked. There are more details
here www.da-soft.com/forums/freedac-osnovnoj-russkij/ra...
And how do you think the changes should go to the database?
To query with a changeable query, you need to tie up another update query in which to write insert, update and delete queries.
And after post, call applyupdates, which will already call update or insert depending on the mode.
Dm.Tviezdi.FieldByName('Departure').AsString := 'Yes';
I suspect it's a getter, not a setter.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question