Hi everybody,
I'm having a little trouble to check if an object was already created.
I tried some examples that I've found on google but without any lucky.
Example:
procedure TForm1.TestClick(Sender: TObject);
var
conn : TADOConnection;
begin
try
if not Assigned(conn) then
conn := TADOConnection.Create(self);
conn.ConnectionString := '';
except
on E : Exception do
begin
ShowMessage('Error: '+E.Message);
end;
end;
end;
On the code above: the conn ":= TADOConnection.Create(self);" never happens, and I get access violation on "conn.ConnectionString := '';"
I have been trying comparisons with nil without success, because the conn is not nil it has an andress.
Thanks.
I'm having a little trouble to check if an object was already created.
I tried some examples that I've found on google but without any lucky.
Example:
procedure TForm1.TestClick(Sender: TObject);
var
conn : TADOConnection;
begin
try
if not Assigned(conn) then
conn := TADOConnection.Create(self);
conn.ConnectionString := '';
except
on E : Exception do
begin
ShowMessage('Error: '+E.Message);
end;
end;
end;
On the code above: the conn ":= TADOConnection.Create(self);" never happens, and I get access violation on "conn.ConnectionString := '';"
I have been trying comparisons with nil without success, because the conn is not nil it has an andress.
Thanks.