Recent

Author Topic: Columns Count in querry result  (Read 1036 times)

Middlecope

  • Jr. Member
  • **
  • Posts: 92
Columns Count in querry result
« on: March 22, 2024, 04:25:10 pm »
openSUSE,  SQLite3
How to determine the count of columns in a querry result set?
I found this in https://sqlite.org/c3ref/column_count.html
Quote
int sqlite3_column_count(sqlite3_stmt *pStmt);
Unfortunately no instructions how to use it

rvk

  • Hero Member
  • *****
  • Posts: 7045
Re: Columns Count in querry result
« Reply #1 on: March 22, 2024, 04:28:39 pm »
Just read out the field count from your dataset.

If TSQLQuery then TSQLQuery.Fieldcount.
You can access them via TSQLQuery.Field array.

Handoko

  • Hero Member
  • *****
  • Posts: 5545
  • My goal: build my own game engine using Lazarus
Re: Columns Count in querry result
« Reply #2 on: March 22, 2024, 04:42:38 pm »
This works for me:

Code: Pascal  [Select][+][-]
  1.   Query.SQL.Text := 'SELECT COUNT(*) FROM tblData;';
  2.   Query.Open;
  3.   TotalRows   := Query.Fields[0].AsInteger;  
  4.   TotalFields := Query.FieldCount;
« Last Edit: March 22, 2024, 04:44:42 pm by Handoko »

Middlecope

  • Jr. Member
  • **
  • Posts: 92
Re: Columns Count in querry result
« Reply #3 on: March 22, 2024, 04:51:14 pm »
Thanks I was to fixed on the word Column that I forget to look at Field,
Sory

 

TinyPortal © 2005-2018