Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
Databases
»
SQLite: Get field names from table
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
AI, NLP and CAI: Text Gen...
by
schuler
[
Today
at 04:26:36 am]
The weird Rewrite bug
by
ojz0r
[
Today
at 03:50:28 am]
Demoscene Square dot flag...
by
KodeZwerg
[
Today
at 03:47:30 am]
How does Castle Game Eng...
by
michalis
[
Today
at 02:51:40 am]
Lazarus for Windows on aa...
by
dsiders
[
Today
at 01:22:37 am]
TBGRABitmap.TextSize retu...
by
circular
[April 16, 2024, 10:52:20 pm]
Have anyone develop UEFI ...
by
440bx
[April 16, 2024, 09:39:52 pm]
For-in loop over constant...
by
VisualLab
[April 16, 2024, 09:15:53 pm]
BUG REPORT: Unable to gen...
by
PascalDragon
[April 16, 2024, 09:02:49 pm]
Lazarus project made on M...
by
Odacir
[April 16, 2024, 08:56:58 pm]
Is it possible to support...
by
PascalDragon
[April 16, 2024, 08:51:36 pm]
CORBA interface and Varia...
by
PascalDragon
[April 16, 2024, 08:35:43 pm]
Macros confuse error mess...
by
PascalDragon
[April 16, 2024, 08:13:25 pm]
Form scaling
by
fxeconomist
[April 16, 2024, 08:09:39 pm]
InstallAware Using Lazaru...
by
Thaddy
[April 16, 2024, 07:21:31 pm]
Post your internal error ...
by
Eugene Loza
[April 16, 2024, 07:12:35 pm]
C-evo: New Horizons 1.3.0...
by
Chronos
[April 16, 2024, 06:32:41 pm]
How can i make this windo...
by
Handoko
[April 16, 2024, 06:23:43 pm]
CocoaInt.CocoaIconUse no ...
by
dsiders
[April 16, 2024, 06:22:10 pm]
Does anyone know why this...
by
Laksen
[April 16, 2024, 06:01:04 pm]
pre-processor symbol when...
by
paule32
[April 16, 2024, 05:11:35 pm]
How are cookies share Web...
by
Thaddy
[April 16, 2024, 04:59:59 pm]
Azure sql database will n...
by
wpflum
[April 16, 2024, 04:04:56 pm]
Values of a custom compon...
by
CM630
[April 16, 2024, 01:42:08 pm]
Arabic text, problem on L...
by
marius.maximus
[April 16, 2024, 12:59:47 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: SQLite: Get field names from table (Read 1847 times)
Milsa
Sr. Member
Posts: 309
SQLite: Get field names from table
«
on:
September 27, 2021, 07:54:59 pm »
I have this fragment of code:
Code: Pascal
[Select]
[+]
[-]
SQL
.
Text
:
=
Format
(
'SELECT * FROM [%s]'
,
[
Name
]
)
;
Open
;
while
not
EOF
do
begin
//detecting field names
Next
;
end
;
Close
;
Can I detect field names from TSQLQuery like "Fields[0].Name"?
Logged
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022
dseligo
Hero Member
Posts: 1219
Re: SQLite: Get field names from table
«
Reply #1 on:
September 28, 2021, 07:49:52 am »
This works with ZEOSlib:
Code: Pascal
[Select]
[+]
[-]
For
i
:
=
0
to
Fields
.
Count
-
1
do
showMessage
(
Fields
[
i
]
.
FieldName
)
;
Logged
Zvoni
Hero Member
Posts: 2327
Re: SQLite: Get field names from table
«
Reply #2 on:
September 28, 2021, 08:39:06 am »
Use "GetFieldNames" of TSQLite3Connection
of TSQLConnection (SQLite3Connection inherits from it)
--> TSQLite3Connection overrides the one from TSQLConnection
https://www.freepascal.org/daily/packages/fcl-db/sqlite3conn/tsqlite3connection.getfieldnames.html
https://www.freepascal.org/docs-html/fcl/sqldb/tsqlconnection.getfieldnames.html
EDIT: Alternative is to fire a PRAGMA-Call from a TSQLQuery-Object
Code: Pascal
[Select]
[+]
[-]
MySQLQuery
.
SQL
.
Text
:
=
'PRAGMA table_info(MyTableName)'
;
MySQLQuery
.
Open
;
«
Last Edit: September 28, 2021, 11:07:16 am by Zvoni
»
Logged
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Milsa
Sr. Member
Posts: 309
Re: SQLite: Get field names from table
«
Reply #3 on:
October 02, 2021, 01:40:49 pm »
Thank you very much. This is solution for me.
Logged
I work with Lazarus 2.2.2, FPC 3.2.2, date 2022-05-15
This information is actual to: 28st Dec 2022
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
Databases
»
SQLite: Get field names from table
TinyPortal
© 2005-2018