Autor Beitrag
MSDevelop
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


Delphi 6 Ent
BeitragVerfasst: Fr 03.09.04 10:49 
Hallo,
habe mal wieder ein Problem :wink:
Ich habe eine Tabelle, wo Zutaten zu einem Rezept stehen und eine, wo der Rezeptename und die Id stehen.
Ich möchte mir alle Zutaten anzeigen lassen, die zu einem Tezept gehören.
ausblenden Quelltext
1:
select * from tbl_zutaten where ID = RezepteID					

Habe das ganze über TQuery realisiert. Setzte ich bei RezepteID eine Wert z.B. '4' ein sucht er mir auch alle Daten, die zum Rezept 4 gehören raus. Kein Problem.
Gebe ich dort aber eine Variable oder den Attributnamen ein kommt eine Fehlermeldung.(Merkmal nicht verfügbar).

Hann mit jemand mit dem Syntax helfen ?
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: Fr 03.09.04 10:51 
Zeig mal den genauen Code, der nicht funktioniert
MSDevelop Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


Delphi 6 Ent
BeitragVerfasst: Fr 03.09.04 10:57 
das ging ja schnell
ausblenden Quelltext
1:
select * from tbl_rezepte,Tbl_binde where RezeptID = '+auswahl+'					


In der Auswahl steht die aktuelle Nummer des Rezeptes.
MSDevelop Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


Delphi 6 Ent
BeitragVerfasst: Fr 03.09.04 11:10 
Habe jetzt den Wert aus der Rezepte Tabelle in den String auswahl geschrieben. Jetzt sagt er mir aber an :
Keine übereinstimmung der Type im Ausdruck.
Wie muss ich die Variable Auswahl declarieren ?
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: Fr 03.09.04 12:06 
auswahl muss in dem Fall ein String sein. Sollte es ein Integer sein, musst Du vorher mit IntToStr(auswahl) einen String daraus machen.
RezeptID sollte in der Datenbank auch eine Zahl sein, wenn es ein String ist, musst Du den Wert von Auswahl in Hochkommata setzen. Im schlimmsten Fall sieht es also so aus:
ausblenden Delphi-Quelltext
1:
Sql.text:='select * from tbl_rezepte,Tbl_binde where RezeptID = '+QuotedStr(IntToStr(auswahl))+'...					

QuotedStr sorgt dabei für die Anführungszeichen, ist geschickter, als wenn man das in Delphi manuell macht, da diese ja in Delphi String-Begrenzer sind.
MSDevelop Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 25


Delphi 6 Ent
BeitragVerfasst: Fr 03.09.04 13:52 
Herzlichen Dank.
Es hat funktioniert. :P