Hi,
I created the following class:
type
TDBConector = class(TCustomClientDataSet)
Conn : TADOConnection;
private
DBConfig : TDBConfig;
public
constructor Create(Aowner : TComponent); overload;
end;
And the constructor where the error occurs, in fact the error occurs on the assignment of the ConnectionString := '';
constructor TDBConector.Create(Aowner : TComponent);
begin
inherited Create(Aowner);
with Conn do
begin
Active := False;
ConnectionString := '';
try
Connected;
except
on E : Exception do
begin
ShowMessage('Error: '+E.message);
end;
end;
end;
end;
If I put this line before use Conn :
"Conn := TADOConnection.Create(Self);"
It works perfectly, but that makes me think, 'conn' shouldn't be created automatically?
So, I need to do that for every class that I declare like that before use?
Finally, If I'll need do what I said above, I'll need free them all on the destructor too, right?
Thanks.
I created the following class:
type
TDBConector = class(TCustomClientDataSet)
Conn : TADOConnection;
private
DBConfig : TDBConfig;
public
constructor Create(Aowner : TComponent); overload;
end;
And the constructor where the error occurs, in fact the error occurs on the assignment of the ConnectionString := '';
constructor TDBConector.Create(Aowner : TComponent);
begin
inherited Create(Aowner);
with Conn do
begin
Active := False;
ConnectionString := '';
try
Connected;
except
on E : Exception do
begin
ShowMessage('Error: '+E.message);
end;
end;
end;
end;
If I put this line before use Conn :
"Conn := TADOConnection.Create(Self);"
It works perfectly, but that makes me think, 'conn' shouldn't be created automatically?
So, I need to do that for every class that I declare like that before use?
Finally, If I'll need do what I said above, I'll need free them all on the destructor too, right?
Thanks.