Recent

Author Topic: How to scroll randomly to any index or record number in Tsqlquery  (Read 5107 times)

heejit

  • Full Member
  • ***
  • Posts: 245
Re: How to scroll randomly to any index or record number in Tsqlquery
« Reply #15 on: December 03, 2018, 08:47:37 pm »
there is no change between that
it is immediate.

One field from sql query Result will be display in list then
user will select any item from list then I will
take index and get the other field value
of selected item and process it.

mangakissa

  • Hero Member
  • *****
  • Posts: 1131
Re: How to scroll randomly to any index or record number in Tsqlquery
« Reply #16 on: December 04, 2018, 08:37:49 am »
How did you determine that particular record number?
 -Provide by user

This is within open close of tsqlquery

Flow as follow
1. Open tsqlquery with a select sql
2. move cursor to given record number
3. get the field data work on it
4. close the tsqlquery.
In this case your scrolling in the dataset with a DBGrid. When the user insert/modify/delete a record SQLdb organise the changes automatically by indexkey (if available). When the user selects a record and goes to another form, take the current id and create a query with it.

Why closing the dataset after each modification.
Lazarus 2.06 (64b) / FPC 3.0.4 / Windows 10
stucked on Delphi 10.3.1

rvk

  • Hero Member
  • *****
  • Posts: 6163
Re: How to scroll randomly to any index or record number in Tsqlquery
« Reply #17 on: December 04, 2018, 08:43:19 am »
Yes, if the data doesn't change you could do it that way.
(Although I still think a dedicated ID field is a better idea.)

But reading your description I wonder if a TDBListBox isn't a better choice. That way you can leave the dataset open and choosing a value will automatically place the dataset-cursor on the chosen record.

heejit

  • Full Member
  • ***
  • Posts: 245
Re: How to scroll randomly to any index or record number in Tsqlquery
« Reply #18 on: December 04, 2018, 10:39:03 am »
I always like to fill data by code
so I can control how I want to display
data instead depend on sql query.

if data is huge then only I use db aware controls

 

TinyPortal © 2005-2018