Creating an ADO handle throws exception if MDAC is missing, especially on Wine. Create that handle in TAdoDBConnection.SetActive, not in TAdoDBConnection.Create, and turn the exception into an EDatabaseError, so the caller gets a handled error. Additionally, display a possible solution in that error popup, which I found on http://forum.winehq.org/viewtopic.php?p=30653 . Fixes issue #2660.

This commit is contained in:
Ansgar Becker
2011-12-26 22:40:32 +00:00
parent 84e4ca9a15
commit d44e55451f

View File

@ -747,7 +747,6 @@ var
i: Integer;
begin
inherited;
FAdoHandle := TAdoConnection.Create(AOwner);
FQuoteChar := '"';
SetLength(FDatatypes, Length(MSSQLDatatypes));
for i:=0 to High(MSSQLDatatypes) do
@ -997,6 +996,19 @@ var
begin
if Value then begin
DoBeforeConnect;
try
// Creating the ADO object throws exceptions if MDAC is missing, especially on Wine
FAdoHandle := TAdoConnection.Create(Owner);
except
on E:Exception do begin
if Pos('Data Access Components', E.Message) > 0 then
raise EDatabaseError.Create(E.Message+CRLF+CRLF+
'On Wine, you can try to install these:'+CRLF+
'sh winetricks mdac28')
else
raise;
end;
end;
NetLib := '';
case Parameters.NetType of
ntMSSQL_NamedPipe: NetLib := 'DBNMPNTW';