我一直在评估 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
这是不可接受的。
有人有同样的问题吗?