* * *

Author Topic: Multible Querys towards SQLite Database  (Read 260 times)


  • New member
  • *
  • Posts: 11
Multible Querys towards SQLite Database
« on: July 12, 2018, 11:43:46 am »

so far posting here always helped me out a lot with progressing with programming in pascal so I am going to give it another shot :)

I have one SQLite Database with one Table. In that table I save sensorvalues of different sensors with a timestamp.
In my application I have 4 different tdbgrid components, with tcharts connected to them.
What I want to do is to display 4 different sensors all over the same time period, at the same time within the program.

A basic example:
Query1: 'select * from dbsensorreadings where sensor = forcesensor';
Query2: 'select * from dbsensorreadings where sensor = temperatursensor';

I want to display these two queries in two different tdbgrids at the same time.

I dont actually know what the best approach to this is. I have tried to create another query component (connected with a transaction and a datasource component) but that won't work. I guess it's because I actually need another dbconnection component.
But despite not getting it to work with another dbconnection component anyways, I then would have to cut the connection of one component, am I right? And that would mean loosing the values within one component, which I dont want to.

My Issue is that I don't know how to approach this problem. I hope you guys understand what I am trying to do, if not I am happy to further explain it. And I really hope you guys can point me in a way on how to do this.

Best Regards


  • Sr. Member
  • ****
  • Posts: 484
Re: Multible Querys towards SQLite Database
« Reply #1 on: July 19, 2018, 02:04:11 pm »
maybe you could retrieve the data for both sensors and filter the dataset to a string grid?
Lazarus 1.8.4 64b on Linux MINT 19 XFCE


  • Sr. Member
  • ****
  • Posts: 499
    • http://www.silentwings.nl
Re: Multible Querys towards SQLite Database
« Reply #2 on: July 19, 2018, 02:12:26 pm »
Why not put those two queries on your form, then put two datasources on the form. One datasource points to query1, the other to query2 and then give dbgrid1 datasource1 as datasource and dbgrid2 datasource2 as datasource.
No extra dbconnection necessary.
Result: two grids, one showing the result of query1, the other shows the result of query2.
« Last Edit: July 19, 2018, 04:39:50 pm by JanRoza »
OS: Windows 10 (64 bit)
Laz: Lazarus 1.8.4 FPC 3.0.4 i386-win32-win32/win64



Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus