Autor Beitrag
Jacer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Di 21.07.09 21:30 
Moin,

ich hoffe ihr könnt mir nochmal helfen. Ich stehe vor einem relativ banalen Problem wobei ich durch einen INSERT INTO Befehl etwas in eine Datenbank schreiben möchte. Die Values sollen hier aus zuvor definierten Variablen bestehen. Und genau hier ist Problem:
Ich erhalte beim Ausführen immer Fehlermeldungen, was wohl mit der Syntax zusammenhängt.

Habe auch per Google nicht die richtige Syntax gefunden ich hoffe ihr könnt mir helfen!

gruß
jacer

_________________
A look in the eyes often says more than a hundred words could ever express.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 21.07.09 21:47 
Ist es so schwer, mit anzugeben, wie dein Befehl aussieht, und welche Fehlermeldung angezeigt wird?

_________________
PROGRAMMER: A device for converting coffee into software.
Jacer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Di 21.07.09 22:10 
Hatte es bisher so versucht:
ausblenden Quelltext
1:
'INSERT INTO Datenbank (Data1,Data2,..) VALUES ('+vData1+', '+vData2+', ...)					

oder
ausblenden Quelltext
1:
'INSERT INTO Datenbank (Data1,Data2,..) VALUES ('+QuotedStr(vData1)+', '+QuotedStr(vData2)+',..)					

Fehlermeldung hab ich folgende erhalten:

"Invalid use of keywords" oder "Value field required"

Moderiert von user profile iconNarses: Quote- durch code-Tags ersetzt

_________________
A look in the eyes often says more than a hundred words could ever express.
Muck
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 98
Erhaltene Danke: 8

Win 8, Win 7, Vista, Win XP
Delphi XE3, Delphi 2009, Delphi 2007, Delphi 5
BeitragVerfasst: Di 21.07.09 23:41 
Hallo,

der Fehler "invalid use of keyword" entseht wenn Du ein Feld mit einem Keyword Namen in einer Datenbank hast.
In dem Fall musst Du das Feld in Anfuherungszeichen setzen und den Tabellennamen davor setzen.

z.B. Feldname MENU aus tabelle GELD.

select ID,MENU from Geld
ist invalid


select ID,Geld."MENU" from Geld
ist erlaubt.

cu

Markus
Jacer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Mi 22.07.09 16:00 
Habe jetzt noch folgende Variante getestet:
ausblenden Quelltext
1:
2:
3:
4:
INSERT INTO Datenbank (Data1,Data2,..) VALUES (:data1, :data2)

MyTable.ParamByName('data1').AsString := editMyVar.Text;
MyTable.ParamByName('data2').AsString := editMyVar2.Text;

Trotzdem erhalte ich den Fehler "Value field required"...

Ist es möglich dass es etwas mit dem Primary Key "ID" zusammenhängt den ich nicht in das Insert Into integriere? Dieser ist AutoIncrement also muss ich ihn doch eigentlich nicht mit in die Value-Liste aufnehmen oder?
Ansonsten sind alle Felder der Datenbank normale Strings.

Weiß einfach nicht woher sonst dieser Fehler kommen soll!

Moderiert von user profile iconNarses: Quote- durch code-Tags ersetzt

_________________
A look in the eyes often says more than a hundred words could ever express.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 22.07.09 16:01 
Ich nehme mal schwer an, dass das ... nur ein Platzhalter darstellt?
Post doch mal bitte den kompletten, ungekürzten SQL String.

_________________
PROGRAMMER: A device for converting coffee into software.
Jacer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Mi 22.07.09 16:29 
Hier Original Insert Befehl:
ausblenden Quelltext
1:
'INSERT INTO Pool.db (Kennzeichen,Modell,FahrgestellNr,LeistungKW,LeistungPS,Firma,Erstzulassung,Farbe,Kraftstoff,Navigationssystem,Name,Vorname,Strasse,Hausnummer,Postleitzahl,Wohnort,Geburtsdatum,Geburtsort'+',FührerscheinNr,FührerscheinKlassen,FührerscheinOrt,FührerscheinDatum,Ausgabedatum,AusgabeZeit,Reiseziel,RückkehrGeplantDatum,RückkehrGeplantZeit) VALUES (:Kennzeichen,:Modell,:FahrgestellNr,:LeistungKW,:LeistungPS,:Firma,:Erstzulassung,'+':Farbe,:Kraftstoff,:Navigationssystem,:Name,:Vorname,:Strasse,:Hausnummer,:Postleitzahl,:Wohnort,:Geburtsdatum,:Geburtsort,:FührerscheinNr,:FührerscheinKlassen,:FührerscheinOrt,:FührerscheinDatum,:AusgabeDatum,:AusgabeZeit,:Reiseziel'+',:RückkehrGeplantDatum,:RückkehrGeplantZeit)';					

Zwischendurch musste ich den String trennen da ich Fehlermeldung aufgrund der begrenzten 255 Zeichen erhielt.

Sobald ich die ID in den Insert Into Befehl integriere, bekomme ich folgende Fehlermeldung:

"INSERT and UPDATE operations are not supported on autoincrement field type."

Moderiert von user profile iconNarses: Quote- durch code-Tags ersetzt

_________________
A look in the eyes often says more than a hundred words could ever express.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 22.07.09 17:13 
Und nun schreibst doch bitte auch noch den Crosspost dazu...
forum.delphi-treff.d...owthread.php?t=27122

_________________
PROGRAMMER: A device for converting coffee into software.
DeddyH
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 22.07.09 17:16 
Und den in der DP gleich dazu ;)
Jacer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Mi 22.07.09 17:21 
Ist das schlimm wenn man in mehreren Foren fragt? :shock:

_________________
A look in the eyes often says more than a hundred words could ever express.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Mi 22.07.09 17:24 

Aber es ist schlimm, wenn du das mit angibst, da sich dann mehrere Leute den Kopf zerbrechen, obwohl das Problem vielleicht woanders schon gelöst wurde.

Steht übrigens in Delphi-Treff auch in den Forenregeln, die du gelesen und akzeptiert hast :P

_________________
PROGRAMMER: A device for converting coffee into software.
Jacer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Mi 22.07.09 17:27 
user profile iconXentar hat folgendes geschrieben Zum zitierten Posting springen:

Aber es ist schlimm, wenn du das mit angibst, da sich dann mehrere Leute den Kopf zerbrechen, obwohl das Problem vielleicht woanders schon gelöst wurde.

Steht übrigens in Delphi-Treff auch in den Forenregeln, die du gelesen und akzeptiert hast :P


Wäre das Problem irgendwie gelöst worden hätte ich das schon angegeben :wink:
Allerdings hat bisher kein Lösungsansatz den gewünschten erfolg gebracht :(

_________________
A look in the eyes often says more than a hundred words could ever express.
Jacer Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Mi 22.07.09 18:07 
Problem gelöst: Habe das Feld ID als nicht required in der Datenbankstruktur markiert und siehe da: der Fehler verschwindet :)

_________________
A look in the eyes often says more than a hundred words could ever express.