Solved

change dataset but not change database

Posted on 2004-08-01
13
512 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
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 2

Expert Comment

by:DarkCore_
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
dark,
thanks for your comments!
0
 
LVL 2

Expert Comment

by:DarkCore_
Comment Utility
Thanks to you corsita! Until the next question ;)

Edu
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

763 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

8 Experts available now in Live!

Get 1:1 Help Now