SQLite3 and Refresh after deleting a record? - delphi

two hours of searching and reading and I am no closer.
Using D5, Zeos v6 SQLite I have Table with the rows displayed in a DBGrid. All fine.
I use
DELETE FROM tblOne WHERE Acct="FirstEntry"
and it deletes the only row that matches. Still all fine - but the DBGrid display stays the same still showing the row just deleted.
I read that closing and opening the TTable assigned to tblOne will refresh the display (as will tblOne.Refresh) which is fine for this test, but sometimes I will not know which Table it is, all I will have is the Table Name. There is no "OPEN", "CLOSE" or "REFRESH" command in SQLite that I can find.
So, how can I refresh the DBGird display to show the record has been deleted?
(edit)
I know I can use
dbgrid1.DataSource.DataSet.Refresh;
but, how does one refresh a display using SQL statements? Or is it not possible?
(edit)
A short line of code would help to describe the process.
Thanks

Related

SQLite fmdb: If I can't delete a column, would deleting the column data be okay?

I currently have an SQLite table that contains the user's information (first name, last name, age, IP address).
However, I don't want the App to store the IP address anymore. The only solutions that I seem to have are to create another table and transfer all the data to it or just delete the address data (set it to NULL). I choose setting it to NULL because it seems easier and the App works very well when I do this with no repercussions. Also, I made it where if the user logs in, the IP address column isn't even going to exist.
My concern is if there is any reason why I shouldn't do this at all? I haven't run into any issues yet, but just in case I thought I'll ask.
Edit: Forgot to mention this, but there is only 1 row of data for the user.
The answer is: you don’t need to drop the column. It’s too much unnecessary work for 1 row of data.
You won’t have any issues because of that spare column
You can “drop” it pretty easily if you like, by just creating a new table with a single row, it sounds scary, but you’ll be surprised with the short time it takes you to do it.

How to implement Auto Save functionality in Delphi?

I am having a task to Auto Save data after every 5 minutes which is filled in more than one forms however I dont want to save the data in the actual dataset. The main aim of auto save is as there are many fields on the form and the user has typed in details spending his valuable time and during this time if the server goes down then the application would crash thereby loosing the data typed in.
If the application has crashed then next time when the connection takes place then a message should pop up saying "Do you want to recover the lost changes?"
once clicked yes then the auto saved form should be shown.
Just a side note my application is working on datasnap model.
Any suggetions how to go about this really appreciated.
Not sure if this is an option, but perhaps you could deploy the application with a lightweight database (such as SQLite or NexusDB)? If you have a lot of forms with a lot of fields/data, this would make a drafts based solution quite easy to implement.
The idea would be to have a "drafts" table in your local database which is a flat table that will contain and hold all of the data that you want to persist until the transactions are committed to the server database.
Save the data in the forms to this local drafts table (as the user enters them in or on a periodic basis). Once the transactions in the forms are committed to the server database, you can delete the draft record from the local drafts table.
If the app crashes and the user signs back on, you will be able to check the local drafts table and pull the data that you need back into the screen fairly quickly and easily.
Hope this helps.

jquery tablesorter issue with page number

I am developing an ASP.NET MVC 4 application using jquery.tablesorter.js, jquery.tablesorter.pager.js and jquery.tablesorter.widget.js. Now I get an issue with this tablesorter, that is, the page number is saved in the local storage.
I understand it is saved for some reasons. The problem is, for example, I last open the 3rd page of the table and leave the session, then re-open a session, it goes to the 3rd page automatically. If, for some reasons, there is not enough items for any item to go to the 3rd page, it simply shows an empty table and pager, and confuses the user.
Any idea is highly appreciated.
Thanks,
A. Zhang
If you don't want the pager to save the page & size, then set the savePages option to false.
If you do want the page to get saved, but you only want to use session storage, then set the storage_useSessionStorage widget option to true.
Please note: the above options only work with my fork of tablesorter.

Firedac / Anydac query issue when using updatesql components

The following question is related to firedac using adquery, updatesql with access database:
First the scenario:
In one of scenario my updatesql gives an error i-e data in the table was not updated, however my dataset after showing error moves to next record. But now data is not in sync with table grid, which is based on this dataset*(adquery)* show updated version which was not successfully applied.
Yet the table still has the old version of the given record.
And my question:
If an error occurs during modification how to know that modifysql
was not run successfully and trap that error to refresh the dataset
as per data in table?

Updating DBGrids in Master-Detail views when updating Cells in Delphi

I am using TADOConn and TADODataSet units pulling data and connected to TDataSources and TDBGrids. I have my DBGrids displaying information properly and editing information in the detail view accurately reflects in the backing database.
What I would like to do is have it so that an update to a field in the detail DBGrid causes a refresh on both data sets so that the most up-to-date data is always displayed.
I have tried putting the refresh calls in several event handlers at various levels of DB access but they all seem to have a similar (but different) issue of reentry.
The best I've been able to come up with so far is getting the Master view updated by calling refresh on the details DBGrid.onColExit event.
If I leave the refresh calls out all together the updated information isn't displayed until the next time the application is run.
Any ideas of how to achieve this? Am I going about it the wrong why? Thanks in advance.
You imply that the changes you make in the DBGrid are posted to the database but are not displayed in the grid or maintained in its dataset and that you must get them back from the database. All the dataset components I have used maintain its copy of the data including all the changes that passed through it to the database. If you expect the data to be changed by triggers or another process, you may need to refresh the data. Then you will have to deal with the possibility that the current record position is lost, i.e. the current record was deleted in the database.
I would try using the Dataset.AfterPost event to initiate the refresh. And I would consider using a Timer to delay the refresh if strange things happen.

Resources