Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Database and Reporting > ado question


Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2001, 07:39 PM
jeisma
Guest
 
Posts: n/a
Question ado question


please someone tell me the implications of this design (aside of course from hugging hardware resources)

i created global recordsets, which initializes and fetches records upon app start-up.

if i need anyone of this recordsets, i just create a clone.

is this ok? i do know some basic facts bout cloning a recordset. im sure u guys could tell me more..


thank you!
Reply With Quote
  #2  
Old 11-21-2001, 07:54 PM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Question Re: ado question

why clone them?

There's no point populating them at startup in case the source data changes.
Just declare the variables Public (if you really need to use them in different modules) and populate/close them when you need them..
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #3  
Old 11-21-2001, 07:56 PM
dcl3500's Avatar
dcl3500 dcl3500 is offline
Mostly Harmless?

Retired Moderator
* Expert *
 
Join Date: Jun 2001
Location: Western Illinois, USA
Posts: 2,398
Default Re: ado question

Never done clones before, but I have always been under the impression that you shouldn't open recordsets and database connections globally. The main reasons for this are as you say....overhead. That said there are other reasons as well that I can think of. 1. Database performance. At least from othe users standpoint. If you have the recordset open and the database connection open for the life of your app then you can run into performance problems (not to mention record lock problems.) 2. Update problems. If someone else changes a record while your app is running then using your clone method you will not see the changes that are being made.

Well all that being said in the end you are the one who has to decide whether these things will affect your app or not. If it is a standalone app then they probably won't affect you too much (aside from the updated info bit.)
__________________
Don

"So long and thanks for all the fish.'" - Douglas Adams.
Reply With Quote
  #4  
Old 11-21-2001, 09:46 PM
jeisma
Guest
 
Posts: n/a
Default Re: ado question

my real intention really is to minimize database reads.

i have several rs that takes an awfully lot of time to open. i guess i really have to check how my app perform using cloned rs.

thanks a lot guys!
Reply With Quote
  #5  
Old 11-21-2001, 09:55 PM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Question Re: ado question

do you really need huge recordsets? Can't you use more specific SQL statements?..
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #6  
Old 11-21-2001, 10:08 PM
loquin's Avatar
loquin loquin is offline
Google Hound

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Arizona, USA
Posts: 12,386
Lightbulb Re: ado question

I'll often open a connection at app startup & keep it open during the life of the app. Recordsets I usually create/open/close/release as needed though.

I'm normally connecting to Oracle, which takes 3 to 5 seconds to get that intial connection established. While this can be somewhat expensive in the number of Oracle sessions, the performance gain in not having to wait for the connection is generally worth it. I do usually add code to close the app after 30 minutes or so of inactivity.
__________________
Lou
"I have my standards. They may be low, but I have them!" ~ Bette Middler
"It's a book about a Spanish guy called Manual. You should read it." ~ Dilbert
"To understand recursion, you must first understand recursion." ~ unknown
Reply With Quote
  #7  
Old 11-21-2001, 10:18 PM
Timbo's Avatar
Timbo Timbo is offline
Green-Eyed

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Bangkok, Thailand
Posts: 10,261
Exclamation Re: ado question

let me just part from the topic for a moment and say what a class picture you have loquin; it's definitely the funniest one I've seen on this forum! Very good - go "The Brain" Homer!! LOL. [img]images/icons/laugh.gif[/img]
__________________
"He's not the Messiah. He's a very naughty boy!" - Brian's mum

Can't find the answer? >> Try something new!
Become a Professional
Reply With Quote
  #8  
Old 11-21-2001, 11:18 PM
jeisma
Guest
 
Posts: n/a
Default Re: ado question

yeah, i got some huge rs.
Reply With Quote
  #9  
Old 11-22-2001, 10:04 AM
dcl3500's Avatar
dcl3500 dcl3500 is offline
Mostly Harmless?

Retired Moderator
* Expert *
 
Join Date: Jun 2001
Location: Western Illinois, USA
Posts: 2,398
Default Re: ado question

I have often thought of doing what you suggest there. Never got around to testing it to see what kind of performance boost that would give my apps. Perhaps it is time to test it out. I really can't see any reason for a problem with the database connection remaining open for the life of the app. It is the recordsets that would concern me the most.
__________________
Don

"So long and thanks for all the fish.'" - Douglas Adams.
Reply With Quote
  #10  
Old 12-06-2001, 04:48 AM
rcbasie
Guest
 
Posts: n/a
Default Re: ado question

I got a little method that i think reduces network traffic.
Declare your connection ojects globally (or global to a form, whichever is best), and then whenever i want to get info from a database, i open a temporary (local) recordset as read-only forward only, open it and then immediatly read all the values into a user-defined type array (ie. type - end type), then close the recordset. I then do all updates by using SQL and a command object (ie. using INSERT INTO and UPDATE ...WHERE). The problem with this approach is that the underlying recordset could change between reading in the values and writing back the updates with the SQL. In my case, i managed to design some error handlers which took care of this. The advantage of this, however is that the forward only, read only recordset is very fast in ADO, and you only have the recordset open for the amount of time you need to read all of the data.Hope this might give you a new angle
Robin
Reply With Quote
  #11  
Old 12-06-2001, 07:27 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: ado question

The method rcbasie suggests is very good in general for dealing with data
on a different database server. I use a variation on it that keeps me from
having to stick the values into arrays, the disconnected recordset. It is
done by using the adLockBatchOptimistic LockType and then setting the
ActiveConnection property of the Recordset to Nothing once the recordset
has been returned. For update, I prefer passing parameters to stored procs
rather than generating the SQLs directly.
__________________
Posting Guidelines
Reply With Quote
  #12  
Old 12-06-2001, 09:22 AM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default Re: ado question

The problem with disconnected recordsets is that they are client side only. Ever tried to pull a half million records or so client side? Hope your users have a LOT of ram on all their stations. (Not putting down disconnected recordsets, they're wonderful, just pointing out a drawback).
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
  #13  
Old 12-06-2001, 09:27 AM
Thinker Thinker is offline
Iron-Fisted Programmer

Retired Moderator
* Guru *
 
Join Date: Jul 2001
Location: Fayetteville Arkansas USA
Posts: 18,127
Default Re: ado question

I agree, and would never use them for that many records. I have been on
record here in the past as saying I can't think of a good reason to ever pull
that many records at a time into a recordset. I deal with one main record
(and its associated detail records, if any) at a time. View, insert, update,
or delete, then go get the next record.
__________________
Posting Guidelines
Reply With Quote
  #14  
Old 12-06-2001, 09:34 AM
reboot's Avatar
reboot reboot is offline
Keeper of foo

Retired Moderator
* Guru *
 
Join Date: Nov 2001
Location: Graceland
Posts: 15,612
Default Re: ado question

If only life were that simple. Unfortunately, many applications don't work 'one record at a time'.
__________________
~ Quod non mortiferum, fortiorem me facit ~

Avatar by lebb
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->