Unidac:解决“trying to modify read-only Field”问题!

后台使用SQL语句中,经常会关联自定义函数视图,而CDS(TClientDataSet)对字段校验比较严格,涉及到的自定义函数或视图输出的字段,都会强制改为ReadOnly为True属性。

当后台使用UniDAC+CDS,关联视图或自定义函数,为了数据一致性,有可能需要在前台界面上修改CDS相关的自定义函数输出的字段,即便是将 该字段设置为 readonlyfalse,或将其字段的 FieldDefs属性的attributesfaReadOnly去掉,系统也会抛出一个异常:trying to modify read-only Field。


解决问题很简单,将TUniQuery.Options.SetFieldsReadOnlyfalse即可。

查一下TUniQuery.Options.SetFieldsReadOnly的帮助,这样写道:

If True, dataset sets the ReadOnly property to True for all fields that do not belong to UpdatingTable or can not be updated. Set this option for datasets that use automatic generation of the update SQL statements only.

posted @   毛小毛  阅读(1595)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示