Autor Beitrag
Tabakbrummel
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 124

win 7
Turbo Delphi, VS 20010 Express
BeitragVerfasst: Mi 15.08.07 12:51 
Hallo

Ich bekomme immer eine Zugriffsverletzung. Was mache ich hier falsch?

Hier ist mal mein Quellcode.

ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, SMDBGrid, Grids, DBGrids, StdCtrls;

type
  TFMain = class(TForm)
    DBGrid1: TDBGrid;
    procedure FormCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    SMDBGrid : TSMDBGrid;
  end;

var
  FMain: TFMain;

implementation

uses DatenModul;

{$R *.dfm}

procedure TFMain.FormCreate(Sender: TObject);
begin
  DBGrid1.DataSource := DM.DS; <---- Hier kommt die Exception
end;

end.


und
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
unit DatenModul;

interface

uses
  SysUtils, Classes, DB, ABSMain;

type
  TDM = class(TDataModule)
    DS: TDataSource;
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
    Database1 : TABSDatabase;
    Session1 : TABSSession;

    Arten: TABSTable;
    ArtenID: TAutoIncField;
    ArtenFischart: TStringField;
    ArtenOrdnung: TStringField;
    ArtenFamilie: TStringField;
    ArtenLatein: TStringField;
    ArtenGruppe: TStringField;
    ArtenMaxLaenge: TFloatField;
    ArtenMaxGewicht: TFloatField;
    ArtenAlter: TFloatField;
    ArtenLaichzeit: TStringField;
    ArtenLebensraum: TStringField;
    ArtenAngeltechnik: TStringField;
    ArtenFormzahl: TFloatField;
    ArtenKapital: TFloatField;
    ArtenImage: TGraphicField;
  end;

var
  DM: TDM;

implementation

uses Main;


{$R *.dfm}

procedure TDM.DataModuleCreate(Sender: TObject);
begin
  Database1 := TABSDatabase.Create(Self);
  Session1 := TABSSession.Create(Self);
  Arten := TABSTable.Create(Self);
  with DataBase1 do
    begin
      Connected := False;
      DatabaseName := 'Angeln';
      DatabaseFileName :=
        'C:\Dokumente und Einstellungen\Brummel\Eigene Dateien\Borland St' +
        'udio-Projekte\Turbo Delphi\Test\Datenbank\Angeln.ABS';
      Exclusive := False;
      MaxConnections := 500;
      MultiUser := False;
      SessionName := 'MySession';
    end;

  with Session1 do
    begin
      SessionName := 'MySession';
      Active := True;
    end;

  with Arten do
    begin
      DatabaseName := 'Angeln';
      SessionName := 'MySession';
      InMemory := False;
      IndexName := 'secFischarten';
      TableName := 'ArtenSuess';
      Exclusive := False;
      Active := True;
    end;
  DS.DataSet := Arten;
  DataBase1.Open;
end;

end.

_________________
MfG
Tabakbrummel
raiguen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 374

WIN 2000prof, WIN XP prof
D7EP, MSSQL, ABSDB
BeitragVerfasst: Mi 15.08.07 22:35 
:roll: Ähm.. so beim ersten Überfliegen der Codeschnippsel kann ich NICHT erkennen, dass du im DataModul irgendeine DataSource hast bzw erstellst, und eine Zuweisung auf DS machst... Somit dürfte doch klar sein, dass es kracht...oder!? :wink: