Recent

Author Topic: How to select a record?  (Read 697 times)

Jvan

  • Full Member
  • ***
  • Posts: 181
How to select a record?
« on: May 28, 2021, 11:39:39 pm »
After executing my SQL query, how can I get the data row of a record?

Something like this:
Code: Pascal  [Select][+][-]
  1. SQLQuery1.Records[15].Fields[3].AsString;
  2.  
  3.  
« Last Edit: May 28, 2021, 11:45:36 pm by Jvan »

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: How to select a record?
« Reply #1 on: May 28, 2021, 11:49:33 pm »
Read it from the query; TSQLQuery is a descendant of TDataset so you can use its Fields and other properties (and methods) to access the data; e.g.:

Code: Pascal  [Select][+][-]
  1. SQLQuery1.RecNo := 15;
  2. SomeString := SQLQuery1.Fields.FieldByNumber(3).AsString;
« Last Edit: May 28, 2021, 11:52:55 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Jvan

  • Full Member
  • ***
  • Posts: 181
Re: How to select a record?
« Reply #2 on: May 28, 2021, 11:55:30 pm »
Thanks.

 

TinyPortal © 2005-2018