Browse Source

* Manual merge of !584

Michaël Van Canneyt 1 month ago
parent
commit
9657da2284
1 changed files with 7 additions and 7 deletions
  1. 7 7
      packages/fcl-db/src/sqldb/odbc/odbcconn.pas

+ 7 - 7
packages/fcl-db/src/sqldb/odbc/odbcconn.pas

@@ -687,7 +687,7 @@ const
   BufferLength = 1024; // should be at least 1024 according to the ODBC specification
   BufferLength = 1024; // should be at least 1024 according to the ODBC specification
 var
 var
   ConnectionString:string;
   ConnectionString:string;
-  OutConnectionString:string;
+  WideConnectionString:widestring;
   ActualLength:SQLSMALLINT;
   ActualLength:SQLSMALLINT;
   DBMS_NAME: array[0..20] of AnsiChar;
   DBMS_NAME: array[0..20] of AnsiChar;
 begin
 begin
@@ -711,14 +711,14 @@ begin
   try
   try
     // connect
     // connect
     ConnectionString:=CreateConnectionString;
     ConnectionString:=CreateConnectionString;
-    SetLength(OutConnectionString,BufferLength-1); // allocate completed connection string buffer (using the ansistring #0 trick)
+    WideConnectionString:=UTF8Decode(ConnectionString);
     CheckResult(
     CheckResult(
-      SQLDriverConnect(FDBCHandle,               // the ODBC connection handle
+      SQLDriverConnectW(FDBCHandle,               // the ODBC connection handle
                        nil,                      // no parent window (would be required for prompts)
                        nil,                      // no parent window (would be required for prompts)
-                       PAnsiChar(ConnectionString),  // the connection string
-                       Length(ConnectionString), // connection string length
-                       @(OutConnectionString[1]),// buffer for storing the completed connection string
-                       BufferLength,             // length of the buffer
+                       PWideChar(WideConnectionString),  // the connection string
+                       Length(WideConnectionString), // connection string length
+                       Nil,// buffer for storing the completed connection string
+                       0,             // length of the buffer
                        ActualLength,             // the actual length of the completed connection string
                        ActualLength,             // the actual length of the completed connection string
                        SQL_DRIVER_NOPROMPT),     // don't prompt for password etc.
                        SQL_DRIVER_NOPROMPT),     // don't prompt for password etc.
       SQL_HANDLE_DBC,FDBCHandle,'Could not connect with connection string "%s".',[ConnectionString]
       SQL_HANDLE_DBC,FDBCHandle,'Could not connect with connection string "%s".',[ConnectionString]