Autor Beitrag
Silvia
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Mo 04.07.05 16:33 
Hallo,

ich möchte gern ein Update auf ein Tabellenfeld erzeugen, aber wie ich es im moment habe funzt es nett!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
ADOQuery1.SQL.Clear;
with ADOQuery1 do begin
  with SQL do begin
    Clear;
    // der Name soll eine Variable sein!
    Text:='UPDATE Tabellenname SET Feldname = '+Name+'';
    tet:=ExecSQL();
  end;
end;


Was mache ich falsch?

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Mo 04.07.05 16:42 
user profile iconSilvia hat folgendes geschrieben:
[...] ich möchte gern ein Update auf ein Tabellenfeld erzeugen, aber wie ich es im moment habe funzt es nett!

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
ADOQuery1.SQL.Clear;
with ADOQuery1 do begin
  with SQL do begin
    Clear;
    // der Name soll eine Variable sein!
    Text:='UPDATE Tabellenname SET Feldname = '+Name+'';
    tet:=ExecSQL();
  end;
end;


Was mache ich falsch?

Das klassische WITH-Problem. Der Bezeichner Name wird in diesem Fall nicht als Deine Variable sondern als Eigenschaft von ADOQuery1 vom Compiler interpretiert.

btw: Was soll das +''; hinter Name? Schau Dir im Bedarfsfall mal die Funktion AnsiQuotedStr an.

btw2: "Funzt nett" ist keine sehr aussagekräfige Fehlermeldung, um es mal gemässigt auszudrücken.

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Mo 04.07.05 17:24 
Ok,

jetzt habe ich es geändert in:

ausblenden Delphi-Quelltext
1:
2:
3:
ADOQuery1.SQL.Clear;
ADOQuery1.SQL.Text:='UPDATE Tabellenname SET Tabellenfeld = '+ Name +'';
ADOQuery1.Open;


und bei ADOQuery1.Open; erscheint die Fehlermeldung das Parameter Name kein Standartwert hat? Häää!!

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt.
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Mo 04.07.05 17:55 
user profile iconSilvia hat folgendes geschrieben:
[...] und bei ADOQuery1.Open; erscheint die Fehlermeldung das Parameter Name kein Standartwert hat?

Was steht in Name drin? Warum beantwortest Du meine Frage nicht oder benutzt AnsiQuotedStr nicht?
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Mo 04.07.05 18:03 
AnsiQuotedStr kapiere ich nicht! wie sieht der Code dann aus!
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Mo 04.07.05 18:04 
ausblenden Delphi-Quelltext
1:
ADOQuery1.SQL.Text:='UPDATE Tabellenname SET Tabellenfeld = ' + AnsiQuotedStr(Name);					

btw: Delphi hat auch eine Hilfe.
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Mo 04.07.05 18:16 
Fehlermeldung: Nicht genügend wirkliche Parameter!
Robert.Wachtel
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 895
Erhaltene Danke: 7

Windows 7 Ultimate x64
D5 Ent, D7 Arch, RAD Studio 2010 Pro, VS 2008
BeitragVerfasst: Mo 04.07.05 18:20 
user profile iconSilvia hat folgendes geschrieben:
Fehlermeldung: Nicht genügend wirkliche Parameter!

Ja, stimmt, da habe ich den zweiten Parameter vergessen. Diesen wirst Du nach Studium der Hilfe zu AnsiQuotedStr bestimmt selber hinzufügen können.
Silvia Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 67



BeitragVerfasst: Mo 04.07.05 18:51 
Ok, danke!