Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.183 Beiträge
 
Delphi 12 Athens
 
#8

AW: Hauptform verschwindet nach Aufruf eines anderen Forms

  Alt 13. Okt 2020, 10:25
mach es mal so frmrekla := Tfrmrekla.Create(Self); // oder nil oder Application oder sonstwas nach Belieben als Owner ,
also selbsterstellte Forms genauso wie jede andere selbsterstellte Komponente.

Obwohl es doch eigentlich dennoch nicht sein sollte, dass die MainForm dadurch verschwindet. (obwohl dieses CreateForm auch an MainForm rumpfuscht)





PS:
Zitat:
Delphi-Quellcode:
qryimgcount.Active := false;
qryimgcount.SQL.Clear;
qryimgcount.SQL.Add('SELECT count(img_name) as anzahl_dokumente FROM beka_attachments WHERE img_kvID='+QuotedStr(main.frmmain.edit_kvID.Text)+' ORDER BY img_id DESC;');
qryimgcount.ExecSQL;
qryimgcount.Active := true;
Warum ExecSQL?

Du hast aber Glück, dass es hier keinen Fehler gibt ... wird nur sinnlos doppelt ausgeführt, das SELECT.

Delphi-Quellcode:
qryimgcount.Close; // verständlicher/lesbarer als qryimgcount.Active := iegendwas;
qryimgcount.SQL.Text := 'SELECT count(img_name) as anzahl_dokumente FROM beka_attachments WHERE img_kvID=:id ORDER BY img_id DESC;';
qryimgcount.ParamByName('id').Text := main.frmmain.edit_kvID.Text:
qryimgcount.Open;
Dann noch das für SQL komplett völlig falsche QuoteStr.
Warum nicht als Parameter? Denn mit diesem QuoteStr kann man keine SQL-Injection verhindern, da es die Pascal-String-Syntax benutzt, anstatt der Syntax für SQL-Strings.


Danneine nicht initialisierte Variable bei TryStrToInt(lblAnzahlReklamation.Caption,count); .
Wieso liest niemand wie Warnungen des Compilers?
Delphi-Quellcode:
if not TryStrToInt(lblAnzahlReklamation.Caption, count) then
  count := 0;
// oder
count := StrToIntDef(lblAnzahlReklamation.Caption, 0);
Und dann mal sehen wann wem auffällt, dass in dem IF-ELSE praktisch alle Codezeilen doppelt sind, abgesehn von Einer (nur um Die bräuchte man das IF machen)
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu (13. Okt 2020 um 10:34 Uhr)
  Mit Zitat antworten Zitat