|
-
Aug 23rd, 2005, 03:05 PM
#1
Thread Starter
Junior Member
Doh! Shared variables have ASP Application scope!!
Doh, I'm converting alot of our existing ASP to ASP.NET. I have been using shared variables and custom collections to save on database hits. Like this:
A Reseller has Customers, and a Customer has Domains, and a Domain has one ParentDomain (self referencing relationship in the database), and a Domain is on a Server. The number of database queries get crazy/repetitive when all the Domains are referencing the same ParentDomain and Server. To save on all the repetitive database hits, I had a shared collection, which instead of creating a new object would return a reference to the existing Domain or Server.
Since I'm only working on my local machine there has been no problem. But today I learned that shared variables are at the Application scope. I had been assuming they would be page scope or maybe session.
Now I'm faced with completely redoing my data access scheme to return datareaders or datasets instead of custom collections, or passing around a reference to some sort of global collection when creating objects.
Any ideas on options? The latter is closest to what I am trying to acheive, but sounds pretty messy.
Thanks,
Jamison
Last edited by jamison; Aug 23rd, 2005 at 03:09 PM.
-
Aug 23rd, 2005, 05:13 PM
#2
Re: Doh! Shared variables have ASP Application scope!!
Use session variables:
Session("SomeVar") = myObj
-
Aug 24th, 2005, 08:10 AM
#3
Thread Starter
Junior Member
Re: Doh! Shared variables have ASP Application scope!!
Hey Bill,
I've thought of that. It just makes for messy code. Now i will need a set of New() subs that accept the reference to the created object. Sigh, I'm not seeing anyway around that.
Jamison
-
Aug 24th, 2005, 08:28 AM
#4
Addicted Member
Re: Doh! Shared variables have ASP Application scope!!
I've used about 30 Private Shared Variables in my web app - they work in a windows form App don't they? Is there a quick and easy way of changing them all?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|