![]() |
Datenbank: Absolute Database • Version: 4 • Zugriff über: Absolute Database
Find all the records in the table and change the text
Liste der Anhänge anzeigen (Anzahl: 1)
Hi everyone.
Please help with the code. I need to retrieve all records entered in Edit1 and rewrite them according Edit2. I use this code, but it overwrites all raises my records in the table. Edit1.Text = Old string Edit2.Text = New string
Delphi-Quellcode:
Thank you all.
var
Options: TLocateOptions; begin Options := Options + [loPartialKey, loCaseInsensitive]; Table1.Close; Table1.Open; Table1.Locate('Permission',Edit1.Text,Options); Table1.First; while not Table1.eof do begin loginForm.ABSTable1.Edit; loginForm.ABSTable1.FieldByName('Permission').AsString := Edit2.Text; loginForm.ABSTable1.Post; loginForm.ABSTable1.next; loginForm.ABSTable1.Locate('Permission',Edit1.Text,Options); end; ShowMessage('Permissions have been changed..'); |
AW: Find all the records in the table and change the text
I would prefer to use a query instead of a table and change the records by SQL.
Delphi-Quellcode:
Query.Close;
Query.SQL.Text := 'UPDATE Tablename SET Permission = :new WHERE Permission = :old'; Query.ParamByName('new').Value := Edit2.Text; Query.ParamByName('old').Value := Edit1.Text; Query.ExecSQL; |
AW: Find all the records in the table and change the text
Delphi-Quellcode:
Didn't test it but should work.
var
Options: TLocateOptions; begin Options := Options + [loPartialKey, loCaseInsensitive]; Table1.Close; Table1.Open; Table1.First; while Table1.Locate('Permission',Edit1.Text,Options) do begin Table1.Edit; Table1.FieldByName('Permission').AsString := Edit2.Text; Table1.Post; end; ShowMessage('Permissions have been changed..'); Though the better version ist the one from DeddyH using SQL. |
AW: Find all the records in the table and change the text
Yes, I'll try SQL.
Thank you; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:13 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz