C
Crazyz
Unregistered / Unconfirmed
GUEST, unregistred user!
如果在initialization中Create会提示错误码'标号没有引用存储'
但在unit1中就不会出错.在另一个程序中我也是这样写的但都不出错
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TAdoc=class(Tcomponent)
private
FAdocc: TAdoConnection;
public
property Adocc: TAdoconnection read FAdocc;
constructor create(AOwner: Tcomponent);override;
end;
var
adoc: TAdoc;
implementation
{ TAdoc }
constructor TAdoc.create(AOwner: Tcomponent);
begin
inherited;
FAdocc := Tadoconnection.Create(nil); //会提示错误码'标号没有引用存储'
end;
initialization
adoc := TAdoc.create(nil);
finalization
end.
***************************************
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm2 = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
adoc := TAdoc.create(nil);//可以
end;
end.
但在unit1中就不会出错.在另一个程序中我也是这样写的但都不出错
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TAdoc=class(Tcomponent)
private
FAdocc: TAdoConnection;
public
property Adocc: TAdoconnection read FAdocc;
constructor create(AOwner: Tcomponent);override;
end;
var
adoc: TAdoc;
implementation
{ TAdoc }
constructor TAdoc.create(AOwner: Tcomponent);
begin
inherited;
FAdocc := Tadoconnection.Create(nil); //会提示错误码'标号没有引用存储'
end;
initialization
adoc := TAdoc.create(nil);
finalization
end.
***************************************
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DB, ADODB;
type
TForm2 = class(TForm)
Button1: TButton;
ADOConnection1: TADOConnection;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
implementation
uses Unit1;
{$R *.dfm}
procedure TForm2.Button1Click(Sender: TObject);
begin
adoc := TAdoc.create(nil);//可以
end;
end.