From e5c8df2ecb402f3545aed1363c39c9c7ca929e12 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 4 Apr 2011 06:16:32 +0000 Subject: [PATCH] Remove driver stuff from MS SQL error messages. --- source/dbconnection.pas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 02815b82..8215eb56 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -1602,10 +1602,19 @@ end; function TAdoDBConnection.GetLastError: String; var + Msg: String; + rx: TRegExpr; E: Error; begin E := FAdoHandle.Errors[FAdoHandle.Errors.Count-1]; - Result := Format(MsgSQLError, [E.NativeError, E.Description]); + Msg := E.Description; + // Remove stuff from driver in message "[DBNETLIB][ConnectionOpen (Connect()).]" + rx := TRegExpr.Create; + rx.Expression := '^\[DBNETLIB\]\[.*\](.+)$'; + if rx.Exec(Msg) then + Msg := rx.Match[1]; + rx.Free; + Result := Format(MsgSQLError, [E.NativeError, Msg]); end;