使用unidac的findkey时发现是区分大小写的,没找到在那可以设置,最后直接修改DBAccess.pas
找到:function TCustomDADataSet.FindKey(const KeyValues: array of const): Boolean;
将:Result := LocateEx(KeyFields, Values, FFindKeyOptions);
修改为:Result := LocateEx(KeyFields, Values, [lxCaseInsensitive]);
保存后重新编译应用就可以。
function TCustomDADataSet.FindKey(const KeyValues: array of const): Boolean; function GetKeyValue(Index: integer): variant; // nearly copied from TField.AssignValue procedure Error; begin DatabaseErrorFmt(SFieldValueError, [IntToStr(Index)]); end; begin Result := Unassigned; with KeyValues[Index] do case VType of vtInteger: Result := Integer(VInteger); vtInt64: Result := VInt64^; vtBoolean: Result := Boolean(VBoolean); {$IFNDEF NEXTGEN} vtChar: Result := String(VChar); {$ENDIF} vtExtended: Result := Extended(VExtended^); {$IFNDEF NEXTGEN} vtString: Result := String(VString^); {$ENDIF} vtPointer, vtObject: if VPointer <> nil then Error; {$IFNDEF NEXTGEN} vtPChar: Result := String(VPChar); vtAnsiString: Result := String(VAnsiString); {$ENDIF} vtCurrency: Result := Currency(VCurrency^); vtVariant: if not VarIsClear(VVariant^) then Result := Variant(VVariant^); vtWideChar: Result := WideString(VWideChar); vtWideString: Result := WideString(VWideString); {$IFDEF VER12P} vtUnicodeString: Result := UnicodeString(VUnicodeString); {$ENDIF} else Error; end; end; var KeyFieldDescs: TFieldDescArray; Values: variant; KeyFieldsCount: integer; KeyFields: TFieldArray; i: integer; begin CheckBrowseMode; FIRecordSet.GetKeyFieldDescs(KeyFieldDescs); Values := Unassigned; // To prevent warning KeyFieldsCount := Length(KeyFieldDescs); SetLength(KeyFields, KeyFieldsCount); case KeyFieldsCount of 0: DatabaseError(SKeyFieldsRequired); 1: begin KeyFields[0] := GetField(KeyFieldDescs[0]); Values := GetKeyValue(0); end; else begin Values := VarArrayCreate([0, KeyFieldsCount - 1], varVariant); for i := 0 to KeyFieldsCount - 1 do begin KeyFields[i] := GetField(KeyFieldDescs[i]); if i <= High(KeyValues) then Values[i] := GetKeyValue(i) else Values[i] := Unassigned; end; end; end; Result := LocateEx(KeyFields, Values,, [lxCaseInsensitive]); end;