|
Registriert seit: 24. Mai 2006 Ort: Bechtheim 19 Beiträge Delphi 2005 Professional |
#1
Hi leute ich hab ein Problem. Ich schreib ein XML Programm das Datein in eine XML Datei schreibt und in ein Datenset schreibt. Jetzt will ich über eine Weiter Funktion die die Daten auswerten. Deswegen lade ich die XML Datei in ein XML Dokument. Aber bei dem Laden kommt immer der Fehler das die Datei nicht vorhanden ist. Das seltsame ist aber, das ich vorher die Datei in ein Datenset lade, oder soger die datei abspeichere.
Der Code ist folgend. Das Problem ist die Procedure für Button 3. Bitte um Unterstützung Danke schon mal
Delphi-Quellcode:
unit Kenoform;
interface uses System.Drawing, System.Collections, System.ComponentModel, System.Windows.Forms, System.Data; type TWinForm = class(System.Windows.Forms.Form) {$REGION 'Vom Designer verwalteter Code'} strict private /// <summary> /// Erforderliche Designervariable. /// </summary> Components: System.ComponentModel.Container; DataGrid1: System.Windows.Forms.DataGrid; Button1: System.Windows.Forms.Button; Button2: System.Windows.Forms.Button; Label1: System.Windows.Forms.Label; Button3: System.Windows.Forms.Button; /// <summary> /// Erforderliche Methode zur Unterstützung des Designers - /// ändern Sie die Methode nicht mit dem Quelltext-Editor /// </summary> procedure InitializeComponent; procedure Button2_Click(sender: System.Object; e: System.EventArgs); procedure Button1_Click(sender: System.Object; e: System.EventArgs); procedure Button3_Click(sender: System.Object; e: System.EventArgs); procedure Button3_Click1(sender: System.Object; e: System.EventArgs); {$ENDREGION} strict protected /// <summary> /// Ressourcen nach der Verwendung bereinigen /// </summary> procedure Dispose(Disposing: Boolean); override; private { Private-Deklarationen } ds : Dataset; Lde : Integer; public constructor Create; end; [assembly: RuntimeRequiredAttribute(TypeOf(TWinForm))] implementation //uses System.IO; uses System.Xml; {$AUTOBOX ON} {$REGION 'Vom Windows Form-Designer erzeugter Code'} /// <summary> /// Erforderliche Methode zur Unterstützung des Designers -- /// ändern Sie die Methode nicht mit dem Quelltext-Editor /// </summary> procedure TWinForm.InitializeComponent; begin Self.DataGrid1 := System.Windows.Forms.DataGrid.Create; Self.Button1 := System.Windows.Forms.Button.Create; Self.Button2 := System.Windows.Forms.Button.Create; Self.Label1 := System.Windows.Forms.Label.Create; Self.Button3 := System.Windows.Forms.Button.Create; (System.ComponentModel.ISupportInitialize(Self.DataGrid1)).BeginInit; Self.SuspendLayout; // // DataGrid1 // Self.DataGrid1.DataMember := ''; Self.DataGrid1.HeaderForeColor := System.Drawing.SystemColors.ControlText; Self.DataGrid1.Location := System.Drawing.Point.Create(136, 40); Self.DataGrid1.Name := 'DataGrid1'; Self.DataGrid1.Size := System.Drawing.Size.Create(792, 552); Self.DataGrid1.TabIndex := 0; // // Button1 // Self.Button1.Location := System.Drawing.Point.Create(32, 104); Self.Button1.Name := 'Button1'; Self.Button1.Size := System.Drawing.Size.Create(96, 32); Self.Button1.TabIndex := 1; Self.Button1.Text := 'Laden'; Include(Self.Button1.Click, Self.Button1_Click); // // Button2 // Self.Button2.Location := System.Drawing.Point.Create(32, 160); Self.Button2.Name := 'Button2'; Self.Button2.Size := System.Drawing.Size.Create(96, 32); Self.Button2.TabIndex := 2; Self.Button2.Text := 'Speichern'; Include(Self.Button2.Click, Self.Button2_Click); // // Label1 // Self.Label1.Location := System.Drawing.Point.Create(144, 608); Self.Label1.Name := 'Label1'; Self.Label1.Size := System.Drawing.Size.Create(168, 24); Self.Label1.TabIndex := 3; Self.Label1.Text := 'Label1'; // // Button3 // Self.Button3.Location := System.Drawing.Point.Create(32, 488); Self.Button3.Name := 'Button3'; Self.Button3.TabIndex := 4; Self.Button3.Text := 'Button3'; Include(Self.Button3.Click, Self.Button3_Click1); // // TWinForm // Self.AutoScaleBaseSize := System.Drawing.Size.Create(5, 13); Self.ClientSize := System.Drawing.Size.Create(944, 646); Self.Controls.Add(Self.Button3); Self.Controls.Add(Self.Label1); Self.Controls.Add(Self.Button2); Self.Controls.Add(Self.Button1); Self.Controls.Add(Self.DataGrid1); Self.Name := 'TWinForm'; Self.Text := 'WinForm'; (System.ComponentModel.ISupportInitialize(Self.DataGrid1)).EndInit; Self.ResumeLayout(False); end; {$ENDREGION} procedure TWinForm.Dispose(Disposing: Boolean); begin if Disposing then begin if Components <> nil then Components.Dispose(); end; inherited Dispose(Disposing); end; constructor TWinForm.Create; var dt : DataTable; col : DataColumn; Lde : integer; begin inherited Create; // // Erforderlich für die Unterstützung des Windows Forms-Designers // InitializeComponent; // // TODO: Fügen Sie nach dem Aufruf von InitializeComponent Konstruktorcode hinzu. // ds := Dataset.Create; dt := DataTable.Create('Keno'); ds.Tables.Add(dt); with dt.Columns.Add('Nr', System.&Type.GetType('System.Int32')) do begin AutoIncrement := True; AutoIncrementStep := 1; end; with dt.Columns.Add('Datum', System.&Type.GetType('System.DateTime')) do begin AllowDBNull := False; DefaultValue := DateTime.Now; end; with dt.Columns.Add('Zahl01', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl02', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl03', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl04', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl05', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl06', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl07', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl08', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl09', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl10', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl11', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl12', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl13', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl14', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl15', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl16', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl17', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl18', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl19', System.&Type.GetType('System.Int32')) do AllowDBNull := False; with dt.Columns.Add('Zahl20', System.&Type.GetType('System.Int32')) do AllowDBNull := False; datagrid1.DataSource := ds; Lde := 0; end; procedure TWinForm.Button3_Click1(sender: System.Object; e: System.EventArgs); var xmldoc : XmlDocument; root, node : XmlNode; begin xmldoc := XmlDocument.Create; try xmldoc.LoadXml('Keno.xml'); // root := xmldoc.DocumentElement; // node := root.SelectSingleNode('Keno/Zahl20'); // label1.Text := node.Name; except MessageBox.Show('Datei ist nicht Vorhanden'); end; end; procedure TWinForm.Button3_Click(sender: System.Object; e: System.EventArgs); begin end; procedure TWinForm.Button1_Click(sender: System.Object; e: System.EventArgs); begin if Lde = 0 then begin try ds.readxml('Keno.xml'); except MessageBox.Show('Datei ist nicht Vorhanden'); end; Lde := 1; end else MessageBox.Show('Datei wurde schon geladen'); end; procedure TWinForm.Button2_Click(sender: System.Object; e: System.EventArgs); begin ds.writexml('Keno.xml'); end; end.
Das Leben ist die Hölle
|
![]() |
Ansicht |
![]() |
![]() |
![]() |
ForumregelnEs ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.
BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus. Trackbacks are an
Pingbacks are an
Refbacks are aus
|
|
Nützliche Links |
Heutige Beiträge |
Sitemap |
Suchen |
Code-Library |
Wer ist online |
Alle Foren als gelesen markieren |
Gehe zu... |
LinkBack |
![]() |
![]() |