Autor Beitrag
jjturbo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 07:50 
Moin Forum,

habe hier ein kleines Programm, welches eine Firebird DB erstellt, dort eine Tabelle erstellt und anzeigt.
Das Programm startet, ich sehe die Daten. Aktiv ist jetzt eine ZTable-Komponente.

Wenn ich jetzt folgende Code ausführe (Per Klick auf einen Button)
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.ButtonSQLClick(Sender: TObject);
var SQLText  :String;
begin
  ZTable1.Active       := false;
  DataSource1.DataSet  := Form1.ZQuery1;
  ZQuery1.Connection   := ZConnection1;
  SQLText              := ComboBoxSQL.Text;
  Form1.ZQuery1.SQL.Clear;
  Form1.ZQuery1.SQL.SetText(PChar(SQLText));

  if Pos('SELECT',UpperCase(SQLText)) = 0
   then Form1.ZQuery1.ExecSQL
   else Form1.ZQuery1.Active := True;

end;


Dann bekomme ich eine Zugriffsverletzung an Adresse 00000000. Aber nur beim ersten Mal. Beim zweiten Klick auf den Button funktioniert es einwandfrei.
Ich verwende die Zeos-Kompos 6.6.6 stable, die Firebird-DLL´s haben das Datum 21.06.2010.

Weiß jemand Rat?

Gruß Oliver

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 20.01.11 08:05 
Du setzt zuerst die Table aktiv und weist danach erst Datenbankkomponenten noch zu. Das kann nicht gut gehen, wenn die von der Table verwendet werden...
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 08:09 
Das Programm startet, der ZTable wird die Datenbankkomponente zugewiesen, Activ auf True gesetzt. Das funktioniert ja auch. Erst jetzt kommt die Query ins Spiel.
Und sorry, ich vergaß zu sagen: Es hat ja auch schon funktioniert :(
Ich habe keine Ahnung warum auf einmal dieser Fehler auftritt...

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 20.01.11 09:39 
Du hast da noch einen Fehler drin (analog weiter unten):
user profile iconjjturbo hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ButtonSQLClick(Sender: TObject);
var SQLText  :String;
begin
  ZTable1.Active       := false;
  DataSource1.DataSet  := Form1.ZQuery1;
Du sprichst eine bestimmte Instanz deines Formulars an, das muss aber nicht die richtige sein...
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 11:00 
Verstehe ich jetzt irgendwie nicht...
Ich könnte theoretisch mehrere Instanzen von TForm1 haben, aber Form1 ist doch DIE Form1 die ich verwende, oder sehe ich da etwas falsch?

Nicht desto trotz... habe "Form1." da entfernt, ändert nichts.

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19339
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 20.01.11 12:35 
user profile iconjjturbo hat folgendes geschrieben Zum zitierten Posting springen:
Ich könnte theoretisch mehrere Instanzen von TForm1 haben, aber Form1 ist doch DIE Form1 die ich verwende, oder sehe ich da etwas falsch?
Nein, Self ist deine aktuelle, in der du bist. In der globalen Variable Form1 liegt die, die da zufällig als letztes reingepackt wurde.
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 12:41 
Also so?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
procedure TForm1.ButtonSQLClick(Sender: TObject);
var SQLText  :String;
begin
  Self.ZTable1.Active       := false;
  Self.DataSource1.DataSet  := Self.ZQuery1;
  Self.ZQuery1.Connection   := Self.ZConnection1;
  SQLText                   := Self.ComboBoxSQL.Text;
  Self.ZQuery1.SQL.Clear;
  Self.ZQuery1.SQL.SetText(PChar(SQLText));

  TRY
  Self.ZQuery1.Active := True;
  EXCEPT
  END;

end;

ändert aber nix :bawling:

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Do 20.01.11 12:49 
1. Was sagt der Debugger ? ( Wo kommt die Zugriffsverletzung )
2. Was soll das self ? Ohne Self gehts ganz genauso
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 13:20 
Das Self kann natürlich weg.
Ein Haltepunkt auf das "End" der Routine, dann bei dem Versuch mit F8 eine Zeile weiter zu springen tritt der Fehler auf:
Zitat:
Im Projekt BlaBlaBla sind zu viele auseinanderfolgende Exceptions aufgetreten: "access violation at 0x00000000: read of adress 0x00000000". Prozess wurde angehalten. Mit einzelne Anweisung oder Start fortsetzen.

(Und dort steht tatsächlich auseinanderfolgende) :)

Wenn ich dann noch mal den Button betätige, dann gehts...

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Do 20.01.11 13:31 
Hast du es mal mit F7 versucht ? Notfalls mit dem CPU-Fenster ?
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 13:34 
Auch mit F7 kommt nach etwa 1-2 Sekunden exakt die gleiche Fehlermeldung.

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 13:39 
Hier mal noch das CPU-Fenster

Screen

Moderiert von user profile iconNarses: BMP->PNG und inline.
Einloggen, um Attachments anzusehen!
_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Do 20.01.11 13:39 
Hast du mal die Debug-DCU's eingebunden ?
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 13:43 
Was meinst Du damit? Die Zeos dcu´s ins Projekt einbinden?

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 14:11 
Ich habe jetzt mal von dem Button aus eine Botschaft an mein Formular geschickt:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.ButtonSQLClick(Sender: TObject);
var SQLText  :String;
begin
  PostMessage(Form1.Handle,MeineMsg,0,0);
end;



Und wenn die Botschaft empfangen wird, dann wird der Code ausgeführt, der vorher im OnClick des Buttons war:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.MyMSG(var Message :TMessage);
var SQLText :String;
begin
  SQLText := 'SELECT * FROM ' + RueckPufferTabelle;

  Form1.ZTable1.Active       := false;
  Form1.DataSource1.DataSet  := Form1.ZQuery1;
  Form1.ZQuery1.Connection   := Form1.ZConnection1;

  Form1.ZQuery1.Active       := false;
  Form1.ZQuery1.SQL.Clear;
  Form1.ZQuery1.SQL.SetText(PChar(SQLText));
  Form1.ZQuery1.Active       := True;
end;

Und so funktioniert es :shock:

_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Do 20.01.11 14:20 
user profile iconjjturbo hat folgendes geschrieben Zum zitierten Posting springen:
Was meinst Du damit? Die Zeos dcu´s ins Projekt einbinden?
Die Zeos sind sowieso schon drin, ich meine die System-DCU's. In Delphi 5 prof gibts unter Projekt | Optionen | Compiler die Möglichkeit, einen Haken bei " Mit Debug-DCU's " zu setzen. Wenn angehakt, kannst du auch durch die VCL debuggen
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Do 20.01.11 14:25 
user profile iconjjturbo hat folgendes geschrieben Zum zitierten Posting springen:
Und wenn die Botschaft empfangen wird, dann wird der Code ausgeführt, der vorher im OnClick des Buttons war.Und so funktioniert es :shock:

Dann wird irgendetwas überschrieben, was nicht überschrieben werden soll. Hast du Bereichs und Overflow-Checking eingeschaltet ?
ALF
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1085
Erhaltene Danke: 53

WinXP, Win7, Win10
Delphi 7 Enterprise, XE
BeitragVerfasst: Do 20.01.11 14:40 
Ich weiss nicht!? Ich hab mal gelesen oder wurde mir gesagt, wenn eine
ausblenden Quelltext
1:
 Zugriffsverletzung an Adresse 00000000					

das etwas zwar declariert aber nicht initiallisiert wurde bzw wieder überschrieben/deaktiviert wurde
Vielleicht sollte er ein bischen mehr Code Zeigen, was vor den Aufruf passiert (o. die gesamte Unit z.B.)
Ansonsten wird es für alle doch nur ein Rätselraten!

Gruss ALf

_________________
Wenn jeder alles kann oder wüsste und keiner hätt' ne Frage mehr, omg, währe dieses Forum leer!


Zuletzt bearbeitet von ALF am Do 20.01.11 14:53, insgesamt 1-mal bearbeitet
jjturbo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 516

Win2000 prof., WinXP prof.
D4 Stand., D5 Prof, D7 Prof, D2007 Prof.
BeitragVerfasst: Do 20.01.11 14:41 
Habe mal mit Debug-DCU´s aktiviert, in der Unit Controls bleibt er hängen wenn der Fehler auftritt

Screen

Moderiert von user profile iconNarses: BMP->PNG und inline.
Einloggen, um Attachments anzusehen!
_________________
Windows XP: Für die einen nur ein Betriebssystem - für die anderen der längste Virus der Welt...
guinnes
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 182
Erhaltene Danke: 14



BeitragVerfasst: Do 20.01.11 14:54 
user profile iconjjturbo hat folgendes geschrieben Zum zitierten Posting springen:
Habe mal mit Debug-DCU´s aktiviert, in der Unit Controls bleibt er hängen wenn der Fehler auftritt
Wenn du jetzt mit F7 durchsteppst, solltest du zumindest die Stelle finden, wo es knallt