Autor Beitrag
tim4vfb
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Do 01.07.04 07:51 
Hallo,

ich möchte ein Eintrag in der Datenbank ändern

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Query1.SQL.Clear
Query1.SQL.Add('UPDATE Datenbankname')
Query1.SQL.Add('set Nachname = '+Edit4.text);
Query1.SQL.Add('WHERE ID = '+Edit1.text);
Query1.Execsql;


Jedoch bekomme ich bei klick auf den Speicher Button die Fehlermeldung: Ungültiger Feldname

Woran liegt das?
Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.
fuser
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23



BeitragVerfasst: Do 01.07.04 08:12 
Hallo tim4vfb
Der Text muss in Hochkommas sonst denkt er, es ist ein Feld.
Das findet er nicht und bringt den Fehler...
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 01.07.04 08:47 
Nimm für sowas am besten QuotedStr, sonst wirst Du verrückt, wenn Du manuell Hochkommata setzt ;-)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Query1.SQL.Clear   
Query1.SQL.Add('UPDATE Datenbankname')   
Query1.SQL.Add('SET Nachname = '+QuotedStr(Edit4.text));   
Query1.SQL.Add('WHERE ID = '+Edit1.text);   
Query1.Execsql;

Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.


Zuletzt bearbeitet von UGrohne am Do 01.07.04 09:10, insgesamt 1-mal bearbeitet
tim4vfb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Do 01.07.04 08:58 
Ja danke hat funktioniert. Aber wie mache ich es denn wenn die Felder in der Datenbank vom Typ Numerisch oder Date sind??

Da sagt er mir dann ja das die Typen nicht kompatibel sind!
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 01.07.04 09:01 
Numerisch kannst Du lassen, auf jeden Fall Ganzzahlen. Kommazahlen müssen als Dezimaltrenner einen Punkt haben. Datumswerte sind in Hochkommata zu setzen, wobei dann aber meistens noch das Format des Datums wichtig ist. Nicht jede Datenbank kann nämlich auch die deutsche Schreibweise lesen.... :(
tim4vfb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Do 01.07.04 09:04 
Mh, und wie würde das dann aussehen?

ausblenden Delphi-Quelltext
1:
2:
3:
query.sql.add(set.....);
query.sql.add(' nachname = 'quotedstr(Edit1.text)')
...


Schreib mal bitte den Code für Datumswerte
Moderiert von user profile iconUGrohne: Code- durch Delphi-Tags ersetzt.
UGrohne
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Veteran
Beiträge: 5502
Erhaltene Danke: 220

Windows 8 , Server 2012
D7 Pro, VS.NET 2012 (C#)
BeitragVerfasst: Do 01.07.04 09:09 
Genauso wie bei Texten, nur musst Du vorher die Datumswerte in Strings biegen ;-)
ausblenden Delphi-Quelltext
1:
QuotedStr(DateToStr(Now))					
tim4vfb Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 45



BeitragVerfasst: Do 01.07.04 09:11 
Ok danke ;)