Browse Source

fcl-db: mysql: fix reporting of connection errors. Pass allocated connection handle (not Nil) to MySQLError procedure to correctly read error code, error message and sqlstate.

git-svn-id: trunk@31306 -
lacak 10 years ago
parent
commit
105af639ce
1 changed files with 2 additions and 3 deletions
  1. 2 3
      packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

+ 2 - 3
packages/fcl-db/src/sqldb/mysql/mysqlconn.inc

@@ -392,9 +392,8 @@ begin
       end;
       end;
     end;
     end;
 
 
-  HMySQL:=mysql_real_connect(HMySQL,PChar(HostName),PChar(UserName),PChar(Password),Nil,APort,Nil,CLIENT_MULTI_RESULTS); //CLIENT_MULTI_RESULTS is required by CALL SQL statement(executes stored procedure), that produces result sets
-  If (HMySQL=Nil) then
-    MySQLError(Nil,SErrServerConnectFailed,Self);
+  if mysql_real_connect(HMySQL,PChar(HostName),PChar(UserName),PChar(Password),Nil,APort,Nil,CLIENT_MULTI_RESULTS) = nil then //CLIENT_MULTI_RESULTS is required by CALL SQL statement(executes stored procedure), that produces result sets
+    MySQLError(HMySQL,SErrServerConnectFailed,Self);
 
 
   if (trim(CharSet) <> '') then
   if (trim(CharSet) <> '') then
     // major_version*10000 + minor_version *100 + sub_version
     // major_version*10000 + minor_version *100 + sub_version