Autor Beitrag
Alibi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Sa 15.03.03 00:43 
Hi,
ich hab folgendes vor:
Ich möchte, dass in einer DBCombobox alle Einträge des Feldes ID stehen. Bei OnChange (Also wenn ein Eintrag gewählt wurde) möchte ich die dazugehörigen Werte in anderen Feldern schreiben.
Wie stell ich das an?
Alibi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Sa 15.03.03 17:18 
Ok, ich hab jetzt eine normale Combobox genommen und mit einem TQuery gearbeitet, funktioniert auch alles soweit wunderbar.
Bloß eine Frage hab ich noch:
Wie stell ich fest, ob in einem Feld der DB überhaupt ein Wert eingetragen wurde? Also wie stell ich fest, ob Query1['bla'] nicht leer ist?
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Sa 15.03.03 21:02 
IsEmpty :shock:

_________________
Gruß
Hansa
kiwicht
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: So 16.03.03 01:14 
oder, noch besser.. 8) .....

Query1['bla'] nicht leer ist?

" Query1['1'] NOT 0 " ?

Ergo: if NOT Query['1'] = '' THEN ...

oder auch

if Query['1'] <> '' then ...


;) .... Mathematische Herleitung, Klasse 8 Wahlfpflicht Mathematik :D

mfg
kiwicht
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 16.03.03 01:41 
nene,

ausblenden Quelltext
1:
if query1.IsEmpty then					


Das bedeutet (falls true) Datenmenge leer.

_________________
Gruß
Hansa
kiwicht
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: So 16.03.03 11:11 
Hm, ok, das ist sicherlich richtig, aber wollte er nicht nur den Inhalt eines Feldes überprüfen?
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 16.03.03 11:31 
IsNull für einzelne Felder.

@Kiwicht : brauchst Du das :?:

_________________
Gruß
Hansa
kiwicht
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1021

Win 7, MacOS
Delphi x, VBA, PHP, ...
BeitragVerfasst: So 16.03.03 19:50 
jupp, ab und an krieg ich z.B. Fehlermeldung, wenn ich den Inhalt eines leeren Feldes an sensible Variablen übergeben will, deshalb bau ich immer ne Sicherheitsabfrage ein...
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 16.03.03 21:31 
Was sind bei Dir "sensible Variable" ? Wenn Du einem integer ein boolean zuordnen willst, ja, das ist dann wirklich sensibel. :P

_________________
Gruß
Hansa
Alibi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: So 16.03.03 23:30 
Hi,
Query1['bla'].IsEmpty klappt leider nicht, das hatte den optimistischsten Eindruck gemacht. :)
ausblenden Quelltext
1:
2:
  if not Query1['bla'].IsEmpty then
    Edit123.Text := Query1['bla'];

Klappt leider nicht, bei der If-Abfrage bekomm ich eine Exception von wegen "Ungültige Variant Operation" o.ä..
Ich möchte das prüfen, weil das Feld "bla" auch durchaus leer sein kann. Wenn es leer ist bekomm ich eine Exception, wenn ich es mit Query1['bla'] ansprechen will.

Und das mit Query1['bla'] <> '' oder not Query1['bla'] = '' klappt insofern nicht, da ich auch hin und wieder ein Integer habe, das quitiert Delphi auch mit einer Exception. :)
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: So 16.03.03 23:39 
papalapap:

Alibi hat folgendes geschrieben:

if not Query1['bla'].IsEmpty then
Edit123.Text := Query1['bla']; <----- und zwar ungefähr hier

Klappt leider nicht, bei der If-Abfrage bekomm ich eine Exception von wegen "Ungültige Variant Operation" o.ä..


:wave: Probier doch mal blabla.IsInteger oder blabla.IsString.....

Trotzdem besteht die Frage immer noch, ob das Dataset geprüft werdeb soll, oder das Feld :?:

_________________
Gruß
Hansa
Alibi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: So 16.03.03 23:58 
Hi,
ne, nur ob dieses eine bestimmte Feld einen Inhalt hat. :)
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mo 17.03.03 00:00 
Wahrscheinlich mußt Du beides überprüfen. Zuerst einmal, ob überhaupt irgendetwas da ist (mit IsEmpty). Falls ja, dann halt die Felder mit IsNull.

_________________
Gruß
Hansa
Alibi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Mo 17.03.03 00:04 
Naja, ich krieg ja schon bei
Query1.['bla'].IsEmpty
eine Exception "Ungültige Variant-Operation" (Genauer Wortlaut). Es erscheint mir logisch, das müsste eigentlich gehen, bloß meint Delphi da was anderes. :)

Ahja, und danke schonmal soweit. :)
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mo 17.03.03 00:11 
wie sieht die Query denn überhaupt aus ?

ohne Quelltext geht wohl nix mehr. Welche DB überhaupt ?

_________________
Gruß
Hansa
Alibi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Mo 17.03.03 00:15 
Das ist eine "normale" Paradox 7 Datenbank, wird ein Fahrtenbuch, bin kurz davor, auf MySQL umzusteigen, das macht weniger Ärger, das funktioniert ohne murren. :)

Momentan sieht die Procedure so aus:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.ComboBox1Change(Sender: TObject);
var
  SQL: String;
begin
  SQL := 'SELECT * FROM Standardfahrten WHERE id='+Copy(ComboBox1.Items[ComboBox1.ItemIndex],4,pos(':',ComboBox1.Items[ComboBox1.ItemIndex])-4);
  Query1.SQL.Clear;
  Query1.SQL.Add(SQL);
  Query1.Open;
  if not Query1['Abfahrtsort'].IsEmpty then
    DBEdit5.Text := Query1['Abfahrtsort'];
  {if not Query1['Ankunftsort'] = Unassigned then
    DBEdit6.Text := Query1['Ankunftsort'];
  if not Query1['Distanz'] = NULL then
    DBEdit7.Text := Query1['Distanz'];     }
end;

Das SQL Statement ist hier *ein wenig* unübersichtlich, aber ich bin mir absolut sicher, dass es funktionert, WENN Werte in den Feldern sind, dann funktioniert das. :)
Bloß kann der Fall eintreten, dass das Feld Distanz z.B. leer ist, deshalb will ich die If-Abfragen machen. Die partout nicht wollen. :)
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mo 17.03.03 00:20 
überprüfe mal im OI, ob die Query bei Active den Wert true oder false stehen hat und gebe Bescheid.

_________________
Gruß
Hansa
Alibi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Mo 17.03.03 00:23 
False, umstellen kann ich es dort nicht.
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Mo 17.03.03 00:27 
Alibi hat folgendes geschrieben:
False, umstellen kann ich es dort nicht.


Das ist aber seltsam. Schreibe trotzdem direkt hinter das begin :Query1.close

_________________
Gruß
Hansa
Alibi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458

Win2K SP3
Delphi 6 Ent
BeitragVerfasst: Mo 17.03.03 00:36 
Bringt nix. :)

Wobei ich das auch als Fehlerquelle ausschließe, ich seh jedenfalls keinen Zusammenhang mit "Ungültige Variant-Operation".