Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

change dataset but not change database

Posted on 2004-08-01
13
Medium Priority
?
531 Views
Last Modified: 2010-04-05
hi all
sorry for my english first...

i want to change the dataset (but not the data inside the database) after making a query, to show the information in a DBGrid with changes.
but i dont want the data of the database really change!! << this is my problem

i know i can do it writing some code inside the ondrawcolumncell event of the DBGrid, redrawing the info.
But i prefer (if it is possible) to change the dataset. This is because, if i want to make a quickreport i have to modify the info again... or other things like that.

0
Comment
Question by:corsita
13 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 11691235
You can make a temporary table with the same structure into your database. Copy and change the data into the temporary one and make a quickreport with it .... When the changed data is not needed, just drop the temporary table from database.

emil
0
 
LVL 12

Expert Comment

by:Ivanov_G
ID: 11691305
Your data in the DB will be changed if you call Post or ApplyUpdates of the dataset (depending on what you are using).

If you want to cancel the changes and not to insert anything in the database, call CancelUpdates.
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 11691421
You can use a component like a Memory Data Set ( you have one in the RX Library - RxMemData ). Just make a query and put all the data in the memory dataset. In this dataset you can change any kind of data, without modifying anything in the database.

Edu
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:jpedef
ID: 11691625
Why don't you use TClientDataset. It doesn't change database before you call ApplyUpdates. Using TClientdataset is easy to use, just add component on the form. Set Datasources Dataset to Clientdataset. Replace current dataset opening method with

  // Dataset_Name.Open; No need for this
  ClientDataset.SetProvider(Dataset_Name);
  ClientDataset.Open;
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 11691678
I still think using a TMemoryData ( from RX ) is more secure, and it's almost as easy to use

   ...
   myDBDataset.Open;
   ...
   MemData.LoadFromDataset( MyDBDataset, 0, lmCopy ); //Copiar la estructura y registros

And that's all, without making BDE ( or Ado ) have pending updates.

Edu
0
 

Author Comment

by:corsita
ID: 11695108
hi, thks for your guides,

Is it a bad idea to set the CacheUpdates property to true of my Query, and never call ApplyUpdates?


DarkCore... if i use MemoryData to copy the table, then how i sholud change the dataset? i have to use the memdata i guess.
MemData.fieldByName('field').Value = newValue ?? im able to do this???

thks,
cheers
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 11698575
Of course, you can do this, and assign a TDataSource, so you can assign it to a grid or any other DBComponent and work as any other Dataset, with same methods and properties.

So you will have all changes in memory, and the database untouched.

Edu
0
 

Author Comment

by:corsita
ID: 11701615
Is it a bad idea to set the CacheUpdates property to true of my Query, and never call ApplyUpdates?

is this risky?
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 11701683
In teory, no, you can have any updates pending with cached updates, only two thinks:

- Cached updates internally uses Paradox tables to store pending changes, so you must beware now you use two database systems ( So any problem could be related to your database or from Paradox )

- An incorrect shutdown ( or cancelUpdates ) can generate a "Directory is busy" Error, and you must restart your computer.

Edu
0
 

Author Comment

by:corsita
ID: 11707037
paradox tables???!

im using ZEOS from www.zeoslib.net, to connect to mysql and firebird.
do u know if this set of components use paradox tables ??? its weird.

Or were you taking about the TQuery that came with Delphi ... ?

cheers!
0
 
LVL 2

Accepted Solution

by:
DarkCore_ earned 400 total points
ID: 11710483
Oh ... sorry, is about BDE TQuery. The "cached updates" of Zeos uses sets of TList in memory to work ( i've seen it just now ), so sure, there's no diference between Zeos CachedUpdates and a TMemoryDataset.

But anyway i still prefer that each class do what they're planned to do. I don't think that let an open dataset which can be posted by any other class (under your control or not) is a good idea. But, of course, if you use cachedupdates then you haven't to install RXLib.

Edu

0
 

Author Comment

by:corsita
ID: 11723648
dark,
thanks for your comments!
0
 
LVL 2

Expert Comment

by:DarkCore_
ID: 11723842
Thanks to you corsita! Until the next question ;)

Edu
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question