Autor Beitrag
kiwicht
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Mo 03.03.03 12:25 
Hallöle..

In meiner DB-Verwaltung will ich öfter mal direkt nach einer SQL-Anweisung zum letzten Datensatz springen, z.B. nachdem ein neuer Datensatz eingefügt wurde. Mein QuellCode sieht dann in etwa so aus:
ausblenden Quelltext
1:
2:
3:
4:
5:
if Application.MessageBox ('Vorgang unwiderruflich erstellen?', 'Vorgang erstellen',33) = 1 then begin
 QueryVorgbuch.SQL.Clear;
 QueryVorgbuch.SQL.Add('SELECT * FROM vorgbuch');
 QueryVorgbuch.Open;
 QueryVorgbuch.Last;


Das führt leider unwiderruflich zu einer Exception: "Grid Index out of Range"
Verwende ich allerdings anstat QueryVorgbuch.Last die sehr unübliche Anweisung:
ausblenden Quelltext
1:
 QueryVorgbuch.MoveBy((QueryVorgbuch.RecordCount));					

klappt alles wie gewünscht.

Was also stimmt mit meiner 1. Version mit "LAST" nicht? Ist das ein Fehler in der BDE oder hab ich was falsch gemacht?

mfg
kiwicht
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 03.03.03 12:58 
Es kann sein, dass Last die erste Zeile als 1 und nicht als 0 erkennt, woraus resultiert, dass der Last Wert 1 zu groß ist und somit Out Of Range wäre.
Was ist denn das für eine Query?

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
kiwicht Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Mo 03.03.03 13:13 
Zitat:
Es kann sein, dass Last die erste Zeile als 1 und nicht als 0 erkennt, woraus resultiert, dass der Last Wert 1 zu groß ist und somit Out Of Range wäre.


Hm, das mag sein, aber ich glaubs nicht wirklich. Weil sonst funktioniert LAST ja, aber halt nicht "kurz" nach einer SELECT-Anweisung.
Zitat:

Was ist denn das für eine Query?


Die BDE-eigene. Aber bitte rate mir jetzt nicht umzusteigen auf n andere DB-Engine..... das wär zuviel Arbeit glaub ich..

mfg
kiwicht
derDoc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 623

Win Vista Prof
D2007 Prof
BeitragVerfasst: Mo 03.03.03 14:28 
Keine Sorge, ich wollte das mit der Query bloß wissen, um dein Problm nachzubauen.

_________________
MfG derDoc
There are only 10 types of people: those who understand binary and those who don't.
kiwicht Threadstarter
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: Mo 03.03.03 14:42 
:wink: ... k, wollt ich nur rein prophylaktisch feststellen... :D