简体   繁体   English

Delphi Firedac - 案例敏感问题

[英]Delphi Firedac - Case Sensitive issue

I am trying to migrate my application from ADO to FireDAC. 我正在尝试将我的应用程序从ADO迁移到FireDAC。 I am using Microsoft SQL Server. 我正在使用Microsoft SQL Server。 My database server was installed with collation SENSITIVE CASE and the database was created with collation INSENSITIVE CASE. 我的数据库服务器安装了排序规则SENSITIVE CASE,数据库是使用排序规则INSENSITIVE CASE创建的。 I did this configuration because my custumers has this configuration. 我做了这个配置,因为我的客户有这个配置。 But when I tried to migrate to FireDAC, the FireDAC driver (MSSQL) look the database collation and change the property "database name" to upper case. 但是当我尝试迁移到FireDAC时,FireDAC驱动程序(MSSQL)查看数据库排序规则并将属性“数据库名称”更改为大写。 After that, many things didnt work, because the FireDAC didn't find the "database name" in sysdatabase. 之后,很多事情都没有用,因为FireDAC没有在sysdatabase中找到“数据库名称”。 Can I turn off this function that change the "database name" property? 我可以关闭此功能来更改“数据库名称”属性吗?

I guess you're looking for the MetaCaseInsCat connection parameter. 我想你正在寻找MetaCaseInsCat连接参数。 Try to disable catalog names case sensitivity autodetection and set it up to be case insensitive: 尝试禁用目录名称区分大小写自动检测并将其设置为不区分大小写:

...
FDConnection1.Params.Add('MetaCaseInsCat=True');
FDConnection1.Connected := True;

I find it that FireDAC is using ansi uppercase conversion to access the database, which in turn causes problems with MSSQL. 我发现FireDAC使用ansi大写转换来访问数据库,这反过来又导致了MSSQL的问题。 In my case it was turkish. 在我的情况下,它是土耳其人。 I found the fix to be easy. 我发现修复很简单。 In OnBeforeConnect of TFDConnection I used: 在TFDConnection的OnBeforeConnect ,我使用了:

Params.Database := TRUpperCase(Params.Database);

Where TRUpperCase is a function that properly converts turkish characters to uppercase(like i to İ, instead of i to I). 其中TRUpperCase是一个将土耳其字符正确转换为大写字母的函数(如i到İ,而不是i到I)。

This is not a direct answer to the OP, but it may help future programmer like me who are having issue with case sensitivity in FireDAC 这不是OP的直接答案,但它可能有助于像我这样在FireDAC中遇到区分大小写问题的未来程序员

I'm using FireDAC with MSSQL. 我正在使用FireDAC和MSSQL。 In order to use the 'LIKE' in a TFDQuery Filter in a non caseSensitive way : TFDQuery.FilterOptions 为了以非caseSensitive方式在TFDQuery Filter中使用'LIKE':TFDQuery.FilterOptions

procedure TFDQuery_MyVersion.SetFilterText(const Value: string);
begin
   FilterOptions := [TFilterOption.foCaseInsensitive];

   inherited SetFilterText(TOldDatabaseSystemToMSSQL.Filter(Value));
end;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM