Autor Beitrag
Andi1982
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Fr 30.05.03 17:18 
Hallo,
wie kann ich nach einem Query-Select abfragen wie viele reihen In der Ergebnistabelle sind??? Also mit RowsAffected gehts nicht.

MfG Andi

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Fr 30.05.03 18:50 
gehts mir rowCount ?
grez
msch
Andi1982 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 497

WinXP HE
D6 Enterprise
BeitragVerfasst: Sa 31.05.03 15:21 
Sowas gibts bei der Querycomponente nicht. Aber irgendwie muss das doch gehen oder net?

_________________
Solange die Bombe tickt ist alles in Ordnung, erst wenn sie damit aufhört wird es problematisch...
MSCH
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1448
Erhaltene Danke: 3

W7 64
XE2, SQL, DevExpress, DevArt, Oracle, SQLServer
BeitragVerfasst: Sa 31.05.03 16:34 
welche kompo nutzt du ?
grez
msch
Luncustaf
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 324

Win 2k
D7 Ent.
BeitragVerfasst: So 01.06.03 08:38 
hi,

das machst du direkt in der sqlanweisung,

ausblenden Delphi-Quelltext
1:
query1.sql.add('SELECT yyy, count(xxx) as Anzahl FROM blubb WHERE bla = "kkk"');					


später kannst du dan nauf die zahl so zugriefen

ausblenden Delphi-Quelltext
1:
query.fieldvalues['anzahl'];					



gr€€tz
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: So 01.06.03 11:27 
Es ist eigentlich ganz einfach:
ausblenden Delphi-Quelltext
1:
RecordCount;					


Du arbeitest nicht mit den Daten im Grid, also hast Du nicht wirklich Zeilen und eine Zeilenanzahl.

Bei RecordCount gibt es aber ein Problem: Du musst vorher ein
FetchAll; machen, da sonst nicht alle gezählt werden, sondern nur z.B. die in einem Grid angezeigten (kleines Feature der IBX-Kompos). Deshalb ist dieser Weg nicht wirklich zu empfehlen, aber möglich (wenns net 100000e Datensätze sind).

@Luncustaf: Das wird so nicht funktionieren, da COUNT nur einen Datensatz zurückgibt, Du das aber mit einer Datenmenge vermischt. Fehler: "Invalid column reference".

Das Beste ist, in einer eigenen Abfrage:
SELECT COUNT(einfeld) AS anzahl FROM einetabelle die Anzahl abzufragen und dann weiterzuarbeiten. Kostet wenig Datenverkehr...
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: So 01.06.03 11:31 
Luncustaf hat folgendes geschrieben:
hi,
später kannst du dan nauf die zahl so zugriefen

ausblenden Delphi-Quelltext
1:
query.fieldvalues['anzahl'];					



Niemals nicht sollte man so auf ein Datenfeld zugreifen. FiedlValues ist Variant, d.h. wenn man das einer Variable zuweist, dann wird erst eine automatische Typumwandlung gemacht, das kostet viel Zeit.

Besser
Query.FieldByName('anzahl').AsInteger Da kann man dann auch AsString o.ä. dahinterhängen.