Browse Source

odbc: fix international column names

git-svn-id: trunk@43881 -
ondrej 5 years ago
parent
commit
166847c7c7

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

@@ -925,7 +925,7 @@ var
   i:integer;
   i:integer;
   ColNameLength,TypeNameLength,DataType,DecimalDigits,Nullable:SQLSMALLINT;
   ColNameLength,TypeNameLength,DataType,DecimalDigits,Nullable:SQLSMALLINT;
   ColumnSize:SQLULEN;
   ColumnSize:SQLULEN;
-  ColName,TypeName:string;
+  ColName,TypeName:RawByteString;
   FieldType:TFieldType;
   FieldType:TFieldType;
   FieldSize:word;
   FieldSize:word;
   AutoIncAttr, FixedPrecScale, Unsigned, Updatable: SQLLEN;
   AutoIncAttr, FixedPrecScale, Unsigned, Updatable: SQLLEN;
@@ -974,6 +974,9 @@ begin
         SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get column name for column %d.',[i]
         SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get column name for column %d.',[i]
       );
       );
     end;
     end;
+    // ColName is received in ANSI - convert to DefaultSystemCodePage
+    SetCodePage(ColName, CodePage, False);
+    SetCodePage(ColName, DefaultSystemCodePage, True);
 
 
     // convert type
     // convert type
     // NOTE: I made some guesses here after I found only limited information about TFieldType; please report any problems
     // NOTE: I made some guesses here after I found only limited information about TFieldType; please report any problems
@@ -1127,6 +1130,9 @@ begin
           SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get datasource dependent type name for column %s.',[ColName]
           SQL_HANDLE_STMT, ODBCCursor.FSTMTHandle, 'Could not get datasource dependent type name for column %s.',[ColName]
         );
         );
       end;
       end;
+      // TypeName is received in ANSI - convert to DefaultSystemCodePage
+      SetCodePage(TypeName, CodePage, False);
+      SetCodePage(TypeName, DefaultSystemCodePage, True);
 
 
       DatabaseErrorFmt('Column %s has an unknown or unsupported column type. Datasource dependent type name: %s. ODBC SQL data type code: %d.', [ColName, TypeName, DataType]);
       DatabaseErrorFmt('Column %s has an unknown or unsupported column type. Datasource dependent type name: %s. ODBC SQL data type code: %d.', [ColName, TypeName, DataType]);
     end;
     end;

+ 1 - 0
packages/fcl-db/src/sqldb/sqldb.pp

@@ -268,6 +268,7 @@ type
 
 
     Property Statements : TThreadList Read FStatements;
     Property Statements : TThreadList Read FStatements;
     property Port: cardinal read GetPort write SetPort;
     property Port: cardinal read GetPort write SetPort;
+    property CodePage: TSystemCodePage read FCodePage;
   public
   public
     constructor Create(AOwner: TComponent); override;
     constructor Create(AOwner: TComponent); override;
     destructor Destroy; override;
     destructor Destroy; override;