Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / September 2007

Tip: Looking for answers? Try searching our database.

ASP.NET Databound controls and connection pools --> How does it work?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Tom - 12 Sep 2007 17:11 GMT
I try to do the following:

Generate a pooled connection in a web application. I use the following code:

In my Global.asax.cs

protected void Application_Start(object sender, EventArgs e)
{
   //Creating a global pooled connection object
   ConnectionStringSettings DBconn =
ConfigurationManager.ConnectionStrings["MyDatabase"];
   SAConnection _conn = new SAConnection(DBconn.ConnectionString);
   Application.Lock();
   Application["DBConnection"] = (SAConnection)_conn;
   Application.UnLock();
}

In the code behind of a web page I have:

protected void Page_Load(object sender, EventArgs e)
{
   SAConnection _conn = (SAConnection)Application["DBConnection"];

   string commandString = "Select * from MarkenAm";
   SACommand command = new SACommand(commandString);

   try
   {
      _conn.Open();
      command.Connection = _conn;
     SADataReader reader =
command.ExecuteReader(CommandBehavior.CloseConnection);
     MarkeDL.DataSource = reader;
     MarkeDL.DataBind();
   }
   finally
   {
      _conn.Close();
   }
}

This works fine but I have to write all the code manually. Is there any
way to tell the designer about my connection pool stored in the
application scope of my web app?? I like to use the click an point
programming feature of the designer, but want all my web pages to use
the same centrally defined connection pool. Is this possible and if so how?

(I wrote tons of web apps in Java, but I am new to ASP.NET)

Thanks for your help

Thomas
bruce barker - 12 Sep 2007 17:30 GMT
you've coded such that no pooling is effectively used, as you are using
the same connection for all requests. also as you do not lock the
connection during use (by sqlcommands), two page requests that try to
use the connection at the same time will fail.

you should only keep the connection string in application, and create a
connection for each request. this will enable pooling to be be used by
every request.

-- bruce (sqlwork.com)

> I try to do the following:
>
[quoted text clipped - 49 lines]
>
> Thomas
Tom - 13 Sep 2007 06:34 GMT
Thanks for that input bruce. So does this mean, that ASP is managing the
pool in the background transparently? In J2EE you have to configure
connection pools in the container (application server) for every
application.

I hope ASP connection pools are also on application context and not on
page context!

Tom
bruce barker schrieb:
> you've coded such that no pooling is effectively used, as you are using
> the same connection for all requests. also as you do not lock the
[quoted text clipped - 6 lines]
>
> -- bruce (sqlwork.com)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.