gpt4 book ai didi

sqlite - 在 TSQLQuery 中使用 as

转载 作者:行者123 更新时间:2023-12-03 15:27:07 29 4
gpt4 key购买 nike

我一直在评估 Delphi XE4(针对 win32 进行编译,但最终平台将是 iOS),我需要创建 SQLite 数据库(没问题)并进行一些查询。这是我想使用的一个查询:

  select id as _id, name, note as description from notes

这是我的代码:

  q := TSQLQuery.Create(nil);
try
q.SQLConnection := MainForm.sqlite1;
q.SQL.Text := sql;
q.Open;
finally
q.Free;
end;

问题是查询返回原始字段名称(id、name、note),而不是我使用的字段名称(_id、name、description)。

  q.Fields[0].FieldName = 'id' //it should be _id
q.Fields[2].FieldName = 'note' //it should be description

这会带来各种各样的问题。使用

  count(*) as myfield

返回

q.Fields[0].FieldName = Column0 //it should be myfield

这是 Not Acceptable 。

有人遇到同样的问题吗?

最佳答案

为了获取字段的正确别名,您必须将 ColumnMetaDataSupported 参数添加到 TSQLConnection 的 Params 属性中。值为 False 的组件。

enter image description here

关于sqlite - 在 TSQLQuery 中使用 as,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16913940/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com