AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken Delphi Find all the records in the table and change the text
Thema durchsuchen
Ansicht
Themen-Optionen

Find all the records in the table and change the text

Ein Thema von danten · begonnen am 25. Jan 2013 · letzter Beitrag vom 25. Jan 2013
Antwort Antwort
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

Find all the records in the table and change the text

  Alt 25. Jan 2013, 10:10
Datenbank: Absolute Database • Version: 4 • Zugriff über: Absolute Database
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:
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..');
Thank you all.
Miniaturansicht angehängter Grafiken
rename.png  
Daniel
  Mit Zitat antworten Zitat
Benutzerbild von DeddyH
DeddyH

Registriert seit: 17. Sep 2006
Ort: Barchfeld
27.542 Beiträge
 
Delphi 11 Alexandria
 
#2

AW: Find all the records in the table and change the text

  Alt 25. Jan 2013, 10:15
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;
Detlef
"Ich habe Angst vor dem Tag, an dem die Technologie unsere menschlichen Interaktionen übertrumpft. Die Welt wird eine Generation von Idioten bekommen." (Albert Einstein)
Dieser Tag ist längst gekommen
  Mit Zitat antworten Zitat
Angel4585

Registriert seit: 4. Okt 2005
Ort: i.d.N.v. Freiburg im Breisgau
2.199 Beiträge
 
Delphi 2010 Professional
 
#3

AW: Find all the records in the table and change the text

  Alt 25. Jan 2013, 10:20
Delphi-Quellcode:
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..');
Didn't test it but should work.
Though the better version ist the one from DeddyH using SQL.
Martin Weber
Ich bin ein Rüsselmops
  Mit Zitat antworten Zitat
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#4

AW: Find all the records in the table and change the text

  Alt 25. Jan 2013, 10:35
Yes, I'll try SQL.

Thank you;
Daniel
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:05 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz