Autor Beitrag
ialla
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Do 04.08.05 12:44 
Hallo bin neu hier und auch in Delphi :P

ich lese hier schon was länger mit und habe immer wieder gelesen, dass es in Delphi möglich ist SQL Statements zu benutzen. Ich programmiere gerade ein kleines tool. Für dieses habe ich über die Datenbankoberfläche eine Paradox 7 Datenbank angelegt. Wie ich aus einem TTable mein DBGrid füllen kann, weiss ich schon aber nicht wie ich es über SQL erledige. SQL kann ich, aber ich verstehe einfach nicht wohin die SQL Statements kommen, damit sie z.B. für mein DBGrid beim Start ausgeführt werden.

Nur damit ihr es besser nachvollziehen könnt. Ich habe folgende Komponenten:
- TTable
- TDataSource
- TQuery
- DBGrid

Das DBGrid soll beim Start schon über eine SQL Anweisung gefüllt werden.

Ich hoffe mir kann noch geholfen werden :lol:



grüße
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 04.08.05 13:00 
Moin moin,

das Welcome spar ich mir mal, wenn du schon länger mitliest :)

Du willst eine TQUery benutzen, dort in die Property SQL dein Statement reinsetzen, ne Datasource da anklemmen und an selbige das Grid ( wie bei der TTable auch ). Dann einfach mit open die Query öffnen und es sollte gehen.

Gruß

noidic

_________________
Bravery calls my name in the sound of the wind in the night...
MarkusB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Do 04.08.05 13:02 
Moin ialla!

Für den Anfang versuch folgendes:

Query-Eigenschaften:
...
Query.Active = true
Query.SQL = dein SQL Statement z.B. selet * from tabelle
...


DataSource-Eigenschaften:
...
DataSource.DataSet = Query
...


DBGrid -Eigenschaften:
...
DBGrid.DataSource = DataSource
...


Viele Grüße
Markus
:gruebel:
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 04.08.05 13:03 
Jo, genau das meinte ich ja :)

_________________
Bravery calls my name in the sound of the wind in the night...
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 04.08.05 13:36 
Aber bitte erst das SQL-Statment setzen und dann active auf True.
Ansonsten gibts bloß wieder eine Fehlermeldung.
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Do 04.08.05 14:15 
hallo und danke für eure Antworten,

user profile iconMarkusB hat folgendes geschrieben:
Moin ialla!
DataSource-Eigenschaften:
...
DataSource.DataSet = Query
...


da scheiterts scchon :cry:
da kann ich nur Table1 auswählen und wenn ich Query1 einfach reinschreibe sagt er, dass es ein ungültiger Wert sei.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 04.08.05 14:17 
Un die TQuery liegt auch auf dem selben Form? Irgendwo vertippt vielleicht? Weil eigentlich müsste das gehen.

_________________
Bravery calls my name in the sound of the wind in the night...
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: Do 04.08.05 14:18 
user profile iconialla hat folgendes geschrieben:
[...] da kann ich nur Table1 auswählen und wenn ich Query1 einfach reinschreibe sagt er, dass es ein ungültiger Wert sei.


Dann hast Du auch keine TQuery auf demselben Formular.
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Do 04.08.05 14:20 
Hi,

:shock: es lag auf dem gleichen Form, aber wurde nicht angezeigt. Jetzt hab ichs rausgeschmissen und wieder neu draufgemacht; jetzt wird's angezeigt. Ich probier jetzt noch den Rest :D
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Do 04.08.05 14:23 
so...

ausblenden Quelltext
1:
2:
3:
Query1.SQL.Clear;
Query1.SQL.Add('SELECT * FROM Artikel');
Query1.open;


das steht drin, das kommt raus, wenn ich die Eigenschaft Active auf true setze:

ausblenden Quelltext
1:
Ungültiges Schlüsselwort					
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 04.08.05 14:34 
Oha, da scheint irgendwas arg faul zu sein. Paradox kenn ich jetzt nicht, aber select und from sollte da eigentlich auch gehen...

_________________
Bravery calls my name in the sound of the wind in the night...
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 04.08.05 14:46 
Du setzt da nirgends Active auf true.
Du machst da ein open. Bist du sicher, dass wir über das selbe reden?
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Do 04.08.05 14:48 
nein bin nicht sicher :D

ich setze den Wert im Objektinspektor auf true.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 04.08.05 14:49 
Dann musst du das SQL-Statement auc im OI eintragen. Da steht bestimmt irgend ein Müll drin.
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 04.08.05 14:50 
Öh, du setzt das Statement zur Laufzeit und im Designer aktivierst du das Query? Das kann nicht gehen!
In dem Fall hat doch das Query noch gar kein Statement, wenns ausgeführt wird.
Spar dir das aktivieren im Objektinspektor, du machst das Query ja eh zur Laufzeit auf.

_________________
Bravery calls my name in the sound of the wind in the night...
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Do 04.08.05 14:51 
hmm...nochma langsam :D
ich klicke im OI auf sql und tipe da meinen oben genannten SQL code ein. Dann klicke ich im OI ganz oben auf "AVTIVE" und setze den Wert auf true und genau dann kommt die Fehlermeldung in einem neuen Fenster.
MarkusB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 68



BeitragVerfasst: Do 04.08.05 14:52 
hallo ialla!

user profile iconialla hat folgendes geschrieben:
so...

ausblenden Quelltext
1:
2:
3:
Query1.SQL.Clear;
Query1.SQL.Add('SELECT * FROM Artikel');
Query1.open;


In welchem Ereignis wird der Code aufgerufen?

Wenn du im Objekt Inspector die drei Punkte (rechts) in Query1.SQL-Eigeschaft anklickst wird ein SQl-Editor geöffnet.
Was steht drin?

Viele Grüße
Markus
:gruebel:
noidic
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 851

Win 2000 Win XP Vista
D7 Ent, SharpDevelop 2.2
BeitragVerfasst: Do 04.08.05 14:53 
Du schreibst das, was du zitiert hast, in den SQL-Editor der Query?

Versuchs mal nur mit dem Statement, ohne Anführungszeichen, ohne sonstigen Code.

_________________
Bravery calls my name in the sound of the wind in the night...
ialla Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 35



BeitragVerfasst: Do 04.08.05 14:55 
user profile iconnoidic hat folgendes geschrieben:
Du schreibst das, was du zitiert hast, in den SQL-Editor der Query?

Versuchs mal nur mit dem Statement, ohne Anführungszeichen, ohne sonstigen Code.
-- ja
- welchen sonstigen code :cry:
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 04.08.05 14:55 
Nur:
ausblenden Quelltext
1:
select * from Artikel