* * *

Author Topic: Multible Querys towards SQLite Database  (Read 1859 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: 524
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 1.8.4 64b on MX Linux "Horizon"

JanRoza

  • Hero Member
  • *****
  • Posts: 501
    • 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

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

 

Recent

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