Solved

change dataset but not change database

Posted on 2004-08-01
13
517 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
How to convert memory stream to PDF file 6 62
Dynamically Created Query 3 56
How to Get Images From Server using App Tethering 11 29
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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