Object sharing

  • Thread starter Thread starter Vik
  • Start date Start date
Vik said:
How to create an object (eg a dataadapter) once and use it in different Web
pages?

If you need to share objects among all users, use the Cache object. If
you need to share objects specific to a particular user, use the Session
object.

Now, might I ask why you want to share a DataAdapter among different
pages? Nine times out of ten, the ideal approach in a Web environment
is to create/open/use/close the database connections *on each page*, and
NOT to attempt to cache such objects.


--

Scott Mitchell
(e-mail address removed)
http://www.4GuysFromRolla.com

* When you think ASP.NET, think 4GuysFromRolla.com!
 
Sorry, my question was not clear.
I want to configure a dataadapter once and use it in the different pages in
design time, so I don't have to configure/reconfige the same dataadapter on
each page.

Vik
 
Hi ViK,

You can create a Component (an object that inherits from IComponent) that
contains the dataadapter. In that component you can set the properties (or
better get them from a configuration file/repository)

Regards,
Leon
 
Thanks.

I already created a Component class and created a dataadapter there. Is this
what you mean?
But I don't know how to access this dataadapter from other classes (Web
pages). Is there an online tutorial about this?

Vik
 
Back
Top