Browse Source

* ftBytes,ftVarBytes support in odbcconnection.setparameters
Patch by Lacak2, Mantis #21116

git-svn-id: trunk@20109 -

marco 13 years ago
parent
commit
b5cc3fbd6c
1 changed files with 14 additions and 2 deletions
  1. 14 2
      packages/fcl-db/src/sqldb/odbc/odbcconn.pas

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

@@ -364,7 +364,8 @@ begin
           SqlType:=SQL_BIGINT;
           ColumnSize:=19;
         end;
-      ftString, ftFixedChar, ftBlob, ftMemo, ftGuid:
+      ftString, ftFixedChar, ftBlob, ftMemo, ftGuid,
+      ftBytes, ftVarBytes:
         begin
           StrVal:=AParams[ParamIndex].AsString;
           StrLenOrInd:=Length(StrVal);
@@ -378,6 +379,11 @@ begin
           ColumnSize:=Size;
           BufferLength:=Size;
           case AParams[ParamIndex].DataType of
+            ftBytes, ftVarBytes:
+              begin
+              CType:=SQL_C_BINARY;
+              SqlType:=SQL_VARBINARY;
+              end;
             ftBlob:
               begin
               CType:=SQL_C_BINARY;
@@ -825,7 +831,13 @@ begin
     ftBytes:              // mapped to TBytesField
       Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_BINARY, buffer, FieldDef.Size, @StrLenOrInd);
     ftVarBytes:           // mapped to TVarBytesField
-      Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_BINARY, buffer, FieldDef.Size, @StrLenOrInd);
+    begin
+      Res:=SQLGetData(ODBCCursor.FSTMTHandle, FieldDef.Index+1, SQL_C_BINARY, buffer+SizeOf(Word), FieldDef.Size, @StrLenOrInd);
+      if StrLenOrInd < 0 then
+        PWord(buffer)^ := 0
+      else
+        PWord(buffer)^ := StrLenOrInd;
+    end;
 {$IF (FPC_VERSION>=2) AND (FPC_RELEASE>=1)}
     ftWideMemo,
 {$ENDIF}