Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 4 of 4 total |
Can I modify a DataSet without storing the changes? |
Sat, May 5 2018 4:36 PM | Permanent Link |
Ralf Mimoun | Hi all,
I need some filter functionality for a dataset. No problem with some placeholders in the SQL statement. Unfortunately, that means a Database.LoadRows to get the filtered data and another Database.LoadRows everytime you open the filter value dialog it can show all column values. I'd like to load the data only once and do the rest with a second DataSet, GetRows and LoadRows. Works like a charm, I just have to delete the rows that are filtered out from the second DataSet. But then it tries to delete that row from the read dataset on the web server. So is there a way to get an unbound / "in memory" dataset without that hurry to store the data somewhere else? |
Sat, May 5 2018 7:12 PM | Permanent Link |
Ralf Mimoun | I just looked into the source code. A virtual TDatabase.Commit method could help. Then you could write a TSinkDatabase classe with an almost empty Commit.
And then I found a solution. It's not that elegant, but it seems to work good enough for me. So, if you need a 100% "in memory" dataset to add some rows, filter data from another dataset (DataSet2.LoadColumns(DataSet1.GetColumns) + DataSet2.LoadRows(DataSet1.GetRows) work great!) or whatever, you just have to create a second Database object: SinkDatabase := TDatabase.Create(Application); SinkDatabase.BeforeCommit := SinkDatabaseBeforeCommit; SinkDataSet := TDataSet.Create(SinkDataBase); // If you want to mirror the structure and content of an existing DataSet SinkDataSet.DataSetName := SourceDataSet.DataSetName; SinkDataSet.LoadColumns(SourceDataSet.GetColumns); SinkDataSet.Open; SinkDataSet.LoadRows(SourceDataSet.GetColumns); // Now do whatever you want and function TForm1.SinkDatabaseBeforeCommit(Sender: TObject): Boolean; begin Result := False; end; That's all, just don't forget to free SinkDatabase and SinkDataSet somewhere. Now nothing goes to the database at the web servers end. |
Sat, May 5 2018 8:44 PM | Permanent Link |
Walter Matte Tactical Business Corporation | See AutoTransactions
If you set AutoTransaction to false it will not do the commit automatically Then after your filter turn AutoCommit back on. I do it all the time. Walter |
Sun, May 6 2018 3:33 AM | Permanent Link |
Ralf Mimoun | Yes, that works too and is way easier to use Thanks for the hint!
|
This web page was last updated on Monday, September 9, 2024 at 03:13 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |