Solved

change dataset but not change database

Posted on 2004-08-01
13
526 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Independent Software Vendors: 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

632 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