简体   繁体   English

解决Delphi 2010或Delphi 2009中的TDatasetProvider中的错误(困难的方式)

[英]Resolving a bug in the TDatasetProvider (the hard way) in Delphi 2010 or Delphi 2009

Like every year I receive a new Delphi version as SA owner and this is what I do : 像每年一样,我以SA所有者的身份收到新的Delphi版本,这就是我要做的:

  1. Install delphi version XX. 安装delphi版本XX。
  2. Run delphi version XX 运行DELPHI XX版
  3. Insert a TSQLConnection component. 插入一个TSQLConnection组件。
  4. Connect it to a Microsoft SQL Server 2000 who will be with us at least for six more years. 将其连接到Microsoft SQL Server 2000,它将与我们至少在一起六年。
  5. Insert a TSQLQuery with a 'select top 1 * from myTable' which is a table with some money fields. 插入带有“从myTable中选择top 1 *”的TSQLQuery,该表是带有一些money字段的表。
  6. insert more components TDatasetProvider, TClientdataset, TDatasource, TDBGrid and a TButton. 插入更多组件TDatasetProvider,TClientdataset,TDatasource,TDBGrid和TButton。
  7. Link everything. 链接一切。
  8. Create An event handler in the DatasetProvider.OnUpdateError with a Raise exception. 在DatasetProvider.OnUpdateError中创建一个带有Raise异常的事件处理程序。
  9. A clientdataset1.applyupdates(0); 一个clientdataset1.applyupdates(0); in the button1click. 在按钮1上单击。
  10. make some changes in the current record. 在当前记录中进行一些更改。
  11. Press the button1 and get the same exception provided by delphi 2005 and above. 按下button1并获得与delphi 2005及更高版本相同的异常。
  12. Renew my corelab or devArt dbx driver for MsSQLServer. 为MsSQLServer更新我的corelab或devArt dbx驱动程序。

Seriously now. 现在认真。 I found some years ago that TDatasetprovider is generating a very simple error: The TFMTBCDField (representation of money field in Delphi) produces incompatible insert/update sql commands for SQL Server 2000 and previous versions. 几年前,我发现TDatasetprovider生成了一个非常简单的错误:TFMTBCDField(Delphi中的money字段表示)为SQL Server 2000和早期版本生成了不兼容的插入/更新sql命令。 The problem is simple the dataset provider produces quoted values for money fields which are not accepted for those sql servers. 问题很简单,数据集提供程序为这些sql服务器不接受的money字段生成报价值。

Example: a table with a varchar field and a money field. 示例:具有varchar字段和money字段的表。 You can use an update like this: 您可以使用如下更新:

UPDATE testtable set MYMONEYFIELD = '1' where MYVARCHARFIELD = 'A' UPDATE测试表集MYMONEYFIELD ='1'其中MYVARCHARFIELD ='A'

for previous versions of SQLServer you need to use: 对于早期版本的SQLServer,您需要使用:

UPDATE testtable set MYMONEYFIELD = 1 where MYVARCHARFIELD = 'A' UPDATE测试表集MYMONEYFIELD = 1,其中MYVARCHARFIELD ='A'

Someone has any workaround for this issue? 有人对此问题有任何解决方法吗?

This is frowned upon by Borland/CodeGear/Embarcadero, but if this is only for your own apps, you can trace down into the VCL source and make the necessary change to the source to ensure you get the correct SQL Generated. Borland / CodeGear / Embarcadero对此一无所知,但是如果这仅适用于您自己的应用程序,则可以追溯到VCL源,并对源进行必要的更改以确保获得正确的SQL生成。 You would need to make this change each time you got a new version or until it was fixed, but it would solve your issue. 每次获得新版本时,都需要进行此更改,或者直到它被修复为止,但这样做可以解决您的问题。

You could submit your change to codegear and see if they would plug it in. 您可以将所做的更改提交给codegear,然后查看他们是否可以插入。

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

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