DataSource Controls :: ADO.NET Application Pooling And SQL Server Processes?
Feb 4, 2010
I'm currently experiencing and issue on whether to say a connection has been left open due to my code or if it's left open due to ADO.NET pooling. Here's a sample of my code:
Public Function ExecuteDataTable(ByVal strStoredProc As String, Optional ByVal objParams As SqlParameter() = Nothing, Optional ByVal cmdType As CommandType = CommandType.StoredProcedure) As DataTable
Dim objDt As New DataTable
Dim objAdapt As New SqlDataAdapter
Dim objParam As SqlParameter
Try
OpenDb()
If Not IsNothing(objParams) Then
AddParams(objParams)
End If
objAdapt.SelectCommand = New SqlCommand
With objAdapt.SelectCommand
[Code].....
Then when I go to open up the SQL Mgmt Studio, I look into the processes and the particular connection that has ran with the SQL that my function runs appears to remain open. So to me, it looks like ADO.NET is performing some kind of pooling. Is it safe to make that conclusion? How would I be able to tell if the connection is available to be used again by the ADO.NET pool?
i expect it to fail at 101 iteration as the default max pool size is 100 and i am not releasing any connection after i open(ie., Not closing or Disposing). But the strange behaviour is i can go up to 230 iterations and then it gives me a timeout error, can not acquire new connection.
When i look in SQL Database for number of connections created it is only 100.
My question is : When connection is not released, how is it able to re-use the previously opened connection.
I'd like to display an animated gif after user presses a submit button which causes postback. I'm following Joe Stagner's tutorial
here. The page worked fine. But now that I've added the update panel around the button and then an update progress with a gif in it, the app doesn't run.
Now, when the button is pressed, the animated gif appears and runs for about three seconds or so (due to the artificial latency added as per the tutorial - System.Threading.Thread.Sleep(3000) ) and then it stops, nothing returns from the server.
What am I doing wrong and what am I not understanding with this Ajax process and the server?
(by the way I'm using the toolscript manager that came with the Ajax control toolkit, don't know if that matters)
Recently I bumped a problem with an asp.net application where seemingly random errors were thrown, although they were all related to the use of a connection object. Coming from Classic ASP, I wrote my pages by creating a connection object at the top of the page, and using that connection throughout the page. The connection object was opened whenever something had to be done with the database and closed immediately after.
Connectionstring: "Data Source=<server>;Initial Catalog=<catalog>;Integrated Security=false;user=<user>;password=<password>;Pooling=False;" So pooling=false.
In my DAL i have more than 100 methods/Function, each and every method am opening the sqlconnection and closing the connection, this is taking too much of time to establish the connection at every time. So what i expect is one common class will create the SqlConnection that will check if the connection is Broken or Closed then create the connection again else return the connection, how to do this(Also i would like to apply ConnectionPooling).
im working with visualstudio 2005 and sql server 2005 c#,and i tried to insert an items to the sql but it gave me this error
Application server error '/ WebSite6'.
The INSERT statement conflicted with the FOREIGN KEY constraint "FK_StudentToCourse_Students".The conflict occurred in database "TopseaUser", table "dbo.Students", column 'id'.
The statement has been terminated.Description: The exception is unhandled occurred during the implementation of the current web request. the stack trace for more information about the error and where the source code. Details exception: System.Data.SqlClient.SqlException: The INSERT statement conflicted with the FOREIGN KEY constraint "FK_StudentToCourse_Students". The conflict occurred in database "TopseaUser", table "dbo.Students", column 'id'.The statement has been terminated.
This error: Line 243: sql_comm.Parameters.AddWithValue ("@ studentId", Convert.ToInt32 (id));
Line 244: sql_comm.Parameters.AddWithValue ("@ CourseId", Convert.ToInt32 (ListBox3.Items [j]. Text.ToString ())); Line 245: sql_comm.ExecuteNonQuery ();
Line 246: split_listbox2 ();
Line 247: sql_conn.Close ();
Source File: c: Documents and Settings Ronen My Documents Visual Studio 2005 WebSites WebSite6 SiteMembers CourseSignUp.aspx.cs line: 245
I'm running IIS 7 on Server 2008, with a single AppPool for an application which is basically just a collection of ASP.NET WebMethods. Some of these methods process for hours before they return. What's weird,is that sometimes when I launch multiple simultaneous requests IIS spins up a single w3wp process (and seems to share it amongst the requests) and other times it spins up multiple w3wp processes.
I want to get all the processes that is meant for a particular session. i.e if there are two persons who are using my web application then i want to get all the processes used by user1 and all the processes used by user2.
I can get all processes by writing Process.GetProcesses() but how to get it in a group.
in my ASP.NET app happen asynchronously (i.e in background threads without any access to HttpContext). Let me take an example of one such action. The app would be deployed to a web farm soon.
The background threads would be processing files deposited to a network share location. So, when the app starts, I create a FilesystemWatcher to monitor activities on the desired network share folder.
As soon as a new file arrives, the code processes it and marks it as completed processing.
The problem is with multiple servers watching the same network share, the same file might get processed on different machines, meaning redundant results. On a single server, I use locking mechanisms to prevent race conditions.
I'm firing the my ModalPopupExtender from a server side button click (bthAuth) and then need to hide that button after my processing is complete. When btnAuth.Visible = False is called it displays the ModalPopupExtender. If I remove this piece of code the window goes away like it should.
When IIS restarts an ASP.Net (2.0) web application, it can either:
Recycle the AppDomain: Unload the AppDomain and load a new AppDomain on the same process (e.g. when HttpRuntime.UnloadAppDomain() is called, when web.config is changed). Recycle the process: unload the AppDomain and load a new one on a new process (e.g. when invoking Recycle command on an AppPool via inetmgr, or when memory limit is reached).
Due to some internal reasons (trouble with legacy native code we depend upon), we cannot allow the first option. We just can't load the application twice on the same process.
Can IIS be somehow told to never allow worker process reuse?
I've tried preventing it myself by tracking whether an application has already started on a process once using a Mutex, and if so - throwing an exception during Application_Start()); I've also tried terminating the process by calling Environment.Exit() during Application_End(). The problem with both methods is that it causes any requests that arrive during Application_End or Application_Start to fail (unlike a manual process recycle, which fails absolutely no requests because they are redirected to the new process right away).
I used visual studio 2008 and sql server 2005(for database) in my website project. After finishing my project i used publish to web option and got the files into an folder. I have installed .NET framework ,IIS, i have also set the remote connection ,firewall setting etc. But when i run i.e., In the IIS manager when i click browse it gives me the following error. Can anyone pls tell me what went wrong in this. My code works fine when run on visual studio 2008. Server Error in '/EBUSINESS' Application.
How can I show loading image for the user while executing long running process in an ASP.Net Ajax application? Is there a way other than using Page Methods? Any ideas?
We're trying to get connection pooling working with uodotnet and currently failing miserably. When we turn connection pooling off everything works as expected, but when we turn it on we often get timeouts or errors with one of the following trace outputs:
2011-03-28T15:09:28 System.Exception: Non-negative number required.
[Code]....
Not all the requests fail (for example, when run through a load testing tool, 7/20 requests failed with the timeout problem).
It seems that the sessions are remaining in the pool and new attempts to create a session are repeating until the timeout limit is reached (30 seconds). We're using uodotnet.dll version 2.1.1.7196 and UniVerse version 10.3. running on an HP-UX server. We've got a single license on the dev machine we're testing on with 10 connections available in the pool (theoretically!). We're writing an ASP.Net web site, and we create a new session in the Page_Load() event which is passed to all UniVerse routines and then call close on the session in Page_Unload()/Page_Error().
to what we're doing wrong? We expected that connection pooling would improve performance, falling back on the standard mechanism if the pool was full, but whereas the non-pooled version works fine with 20 simultaneous requests, the pooled version regularly fails. We've set the connection pooling on in the application's web.config, setting MinPoolSize to 1 and MaxPoolSize to 10, leaving everything else at the defaults.
I'm not having much fun with connection pooling. The website I've written does dip into the SQL server all the time and quite a lot of times per page. Every time I nip into the SQL Server to get or set something I open a connection...
comGeneral.Connection.Open()
... do or get what I need and then close it. From what I've read any of the following should close the connection and return "one connection" (?) to the pool (top one, only if reading)....
... but that's not really working for me and I keep hitting the default max 100 open pools. So I've been doing all 3 of the above (again, top one, only if reading). But alas, still the stupid thing (Yes, I am aware I'm the stupid one) keeps hitting the max.
My new plan is to set pooling to false (pooling = false ?) across the entire website and take the performance hit which wont be terrible because I don't really do anything too demanding. Trouble is I don't know how, other than setting Pooling = False, but where exactly in the webconfig would this bit of code go?
My project use asp.net web form, and I code it with masterpage, page and mutil webcontrol to render a web page. A problem, request it slowly. I want to increase performace. I use webservice to request data, whole web control has code to request data from webservice.
I review code, and I think if my web used webservice pooling to render a webpage. But I haven't know how to code better, remove all webcontrol, and move their code to create a web page like asp web page (not asp.net)! using only one webservice to request data...
If I open a connection and don't close it after query execution completes, store it somewhere, and use it next time a request comes in, isn't it something similar to what .net does? Is it possible to maintain a pool of connections according to our requirements without depending on ADO.NET's internal mechanism? In case of ODBC, I read somewhere that connection pooling will have to be enabled from ODBC datasources and that it cannot be set from within .net. What if I open a few ODB connections, leave them open and use those whenever a request comes in and close all of them when I know that I dont need them anymore. How is it different from connection pooling?
I am designing an ASP.NET (3.5) web application that connects to a Rocket Software UniVerse database.
I am shooting for a RESTful design and a MVC pattern. Rocket provides a .NET library called UniObjects.NET which handles everything for connecting and retrieving information from the database.
What would be the best way to in general to log my users into the database, then use that session via connection pooling? I see that in 3.5 there is the ASP.NET Routing Infrastructure and that looks promising am I in the right direction on this? Also does C# support decorators like Python and Java?