Recent

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

phr0x

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

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

tudi_x

  • Hero Member
  • *****
  • Posts: 532
Re: Multible Querys towards SQLite Database
« Reply #1 on: July 19, 2018, 02:04:11 pm »
hi,
maybe you could retrieve the data for both sensors and filter the dataset to a string grid?
Lazarus 2.0.2 64b on Debian LXDE 10

JanRoza

  • Hero Member
  • *****
  • Posts: 672
    • 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) / Linux Mint (64 bit)
       Lazarus 3.2 FPC 3.2.2
       CodeTyphon 8.40 FPC 3.3.1

phr0x

  • New Member
  • *
  • Posts: 20
Re: Multible Querys towards SQLite Database
« Reply #3 on: July 25, 2018, 01:11:49 pm »
@JanRoza: Yup that is what I did after trying a few things out. Just didn't know it was possible like that.

Thank you for you help guys :)

Best Regards

 

TinyPortal © 2005-2018