From d44e55451f9303da93d2f5ac29a3f7c1b58dfdc6 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 26 Dec 2011 22:40:32 +0000 Subject: [PATCH] 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. --- source/dbconnection.pas | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index a68fb57a..ed94a4c9 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -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';