Question

I've been evaluating Delphi XE4 (compiling against win32, but final platform will be iOS) and I need to create SQLite database (no problem with that) and make some queries. This is one query I'd 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 query returns original field names (id, name, note), 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

That makes all sorts of problems. Using

  count(*) as myfield

returns

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

that is not acceptable.

Anybody had same problems?

Was it helpful?

Solution

In order to get the proper alias names of the fields, you must add the ColumnMetaDataSupported param to the Params property of the TSQLConnectioncomponent with the False value.

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top