Like in TSQLQuery

I am evaluating Delphi XE4 (compilation against win32, but the final platform will be iOS) and I need to create a SQLite database (no problem) and make some queries. This is one of the queries I would like to use:

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

And this is my code:

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

The problem is that the query returns the original field names (id, name, note), and not the one I used (_id, name, description).

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

This creates all kinds of problems. Using

  count(*) as myfield 

returns

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

which is unacceptable.

Did anyone have a problem?

+4
source share
1 answer

To get the correct field aliases, you must add the ColumnMetaDataSupported parameter to the Params TSQLConnection property with the value False .

enter image description here

+5
source

Source: https://habr.com/ru/post/1484361/


All Articles