Click to See Complete Forum and Search --> : 2 database kindof questions


BlackSun
February 21st, 2005, 03:13 PM
Hi again, more newbie troubels ...

I'm writing an app which reads from a database and displays the results in a list control.. Now I have 2 questions about how to do stuff..

1. Depending on what the user chooses, sometimes only part of the db is to be shown, so which of these ideas is the better to use ?
Either I plan to read the whole db into an array or something and then do all the filtering on that (in other words, just put the posts that comes through the filter in the lists). I guess this would be faster if the user chooses to do a lot of searches, or am I wrong here ? And I guess the array would be quite big.

The other way is to do all the searches in the db, but if the base is big, would this be slower ?
I guess this could be timed, but I'll never be able to to such a big db.

2. About saving.. In the app there is a save option, so I don't want any changes to be made until user chooses to save. How is this usually done ? One way I'm thinking of is to make a copy of the db and let the user do it's operations on this, and when it's time to save simply copy this over the original file..
Or else I don't know how to do.. Is there any way to not finalise the changes in the db until Save is pressed ? I'm using ODBC, and as I understand it changes are saved instantly, or is there any way to go around this ?

TIA
BlackSun

GCDEF
February 21st, 2005, 03:19 PM
1)

Unless the database is small, using the database to do the selections should be much more efficient as long as the columns you're filtering on are indexed.

2)

Probably not a very good design, especially in a multi-user environment. Read up on database transaction processing.

Andreas Masur
February 21st, 2005, 04:41 PM
[ Moved thread ]

BlackSun
February 21st, 2005, 04:57 PM
Well it's not a multiuser env. it's just an app that will be used by one person. And I can't find anything on ex msdn on when the changes to the db are saved, if it is when the app makes its update, insert or whatever it is, or when its is closed..
And (apparently I have become very bad at searching info) I can't find some good tutorial on how Save-situations/problems are usually solved ..

erickwidya
February 21st, 2005, 09:48 PM
BlackSun for ur 1st question
check this (http://www.codeguru.com/forum/showthread.php?t=325533) (see Dmorley's suggestion)

2. About saving.. In the app there is a save option, so I don't want any changes to be made until user chooses to save. How is this usually done ? well usually it save when user click Save button :p.. is it involved more than 2 records or just like updating 1 record?

One way I'm thinking of is to make a copy of the db and let the user do it's operations on this, and when it's time to save simply copy this over the original file..not a good method..don't try that..

And I can't find anything on ex msdn on when the changes to the db are saved, if it is when the app makes its update, insert or whatever it is, or when its is closed..not quite understand this. it usually save when u call .update method is using Recordset object or .committrans if u using Connection object or if u move to other record using .move syntax