Forum > Database

SQLite DB read TBGrid while writing

(1/1)

phr0x:
Hey there,

I have a probably fairly simple issue, just don't know where to look for the solution that's why I am posting here.
First what I want to do:
I want to save data out of a constant stream I get via an USB connection. And while doing so I want to be able to have a look at the data with a TDBGrid Component and a Tchart Component.

I have no problem with saving the data coming in or displaying it as it is. My Problem is that I want to see my Data in the Grid while I am writing. Every time I write into the DB I open and close the TSQL.Query and that's what I think causes the issue. When I filter my DB to display the Results in the Grid and then afterwards continue writing into the DB the Data shown in the Grid just dissapears again. But I want to keep that data there to see it and use it in a chart and for calculation.
Can you guys pinpoint me in a direction where I can get a solution for this or do you maybe even have a solution already?

Short example:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---//this is what I do on creating the formDBConnection.Connected := True;SQLTransaction1.Active := True;SQLQuery1.Open; //this is the basics of the function I use to write into the DBSQLQuery1.SQL.Text := 'INSERT INTO db (sensor) values (:PH_val)';SQL.Query1.Params.ParamByName('PH_val').AsInteger := 2SQLQuery.ExecSQL;SQLTransaction1.Commit; //this is the basics of the function I use to filter and display the valus in a gridSQLQuery1.SQL.Text := 'select * from db';SQLQuery1.Open;SQLQUery1.Applyupdates; 
Best Regards  :D

JanRoza:
Why not use commitretain instead of commit? That updates your datbase without closing it.

phr0x:
Well, that solved it. Thank you very much.  :D

JanRoza:
You're welcome!  :D

Navigation

[0] Message Index

Go to full version