Solved

change dataset but not change database

Posted on 2004-08-01
13
514 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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 100 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

861 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now