urgent: connection pooling error

dotnet framework

    Next

  • 1. SqlConnection: 1 long or many short...
    Hi, I was wondering if it is better/worse to have 1 SqlConnection as a public object and initalized after i.e. the login to the application, or to reconnect each time before some database action is needed in a piece of code, and of course to deconnect directly after having executed the sql-statement. I imagine that having the connection setup at the start of the application would consume a license on the sql-server for the life- time of the application, where disconnecting/reconnection at each sql- task would limit this. But, if licences aren't an issue, would there be other pro's/con's to have/not have the connection setup at the start and use it for all action within the application? Points to considder: - transactions - performance - licences - good practice - logging of ... - ... Thanks
  • 2. boot up
    I have a windows application that runs when the PC first boots up, done by adding an item to the registry: Microsoft.Win32.RegistryKey rkApp = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\ \Windows\\CurrentVersion\\Run", true); rkApp.SetValue("ApplicationName", Application.ExecutablePath.ToString()); The first thing this application does is access an SQL Server 2005 Express Edition database on the local machine. My problem is that occasionally the applicatiom starts before the database has started properly and the application throws an error because it can't see the database. So does anyone have any idea how to fix this? Preferably by somehow ensuring that my application only starts after the database is up and running, but I will take all suggestions. Thanks, Joseph
  • 3. Slow app closing when SqlConnection used with Pooling=true
    Using dotnet 2.0. Console app to reproduce issue : == using System; using System.Collections.Generic; using System.Text; using System.Data.SqlClient; namespace DBSlow { class Program { static void Main(string[] args) { using (SqlConnection conn = new SqlConnection("Integrated Security=true;database=YourDB;server=.;Pooling=true")) { conn.Open(); using (SqlCommand cmd = new SqlCommand("select GETDATE()")) // just do something with SQL server { cmd.Connection = conn; cmd.ExecuteNonQuery(); } } Console.WriteLine("done"); } } } == When this code is run, I'm seeing about a 1 to 2 second delay from the time that : "done" gets displayed, to the time that the application terminates. i.e. run it from a command shell, and it should be easy to see. When I turn connection pooling off (by using "Pooling=false" in connection string), I don't see this delay. The delay is a problem for us, because in real life, the real app can get called many times in a batch file. Any ideas if this delay is by design for connection pooling ? Any way to reduce/eliminate it with connection pooling on ?
  • 4. OleDb Connection to XML File
    I would like to create an OleDb connection to an XML File, but I cannot find information about the connection string parameters. Is this possible? I've got some parameters that an application uses and I have decided that it would be best to store it in a database-like storage area. I figured I could store the values in a CSV, XLS, or MDB file and maintain the parameters through a OleDb connection. However, I wondered if I could use XML as well. I don't want to rely on a server connection and I don't want to load anything on the client. For what it's worth, I'm using VS2005.
  • 5. Getting total for a field in a datatable.
    Is there a way to get a total for a field in a datatable. In SQL I would do something like: select sum(Cost) from TEST TIA - Jeff

urgent: connection pooling error

Postby Param R. » Sat, 13 Nov 2004 06:01:58 GMT

Hi all, I have a web service that opens a sqlconnection to the db and does 
some work. Just recently I have begun getting the following error on a 
frequent basis:

Timeout expired.The timeout period elapsed prior to obtaining a connection 
from the pool.This may have occurred because all pooled connections were in
use and max pool size was reached.

I have verified that my web service is closing connections. Why is this 
happening? Can I increase the max pool size? How?

thanks,
Param



Re: urgent: connection pooling error

Postby bruce barker » Sat, 13 Nov 2004 09:23:08 GMT

thre are two common causes:

1) coding error leading to not closing connections
2) too many concurent request (more requests running than pool size). this
is anot very likly, as you generaaly run out of threads first.

i'd guess the first. if its the second increase the pool size in the
connection string.


-- bruce (sqlwork.com)






| Hi all, I have a web service that opens a sqlconnection to the db and does
| some work. Just recently I have begun getting the following error on a
| frequent basis:
|
| Timeout expired.The timeout period elapsed prior to obtaining a connection
| from the pool.This may have occurred because all pooled connections were
in
| use and max pool size was reached.
|
| I have verified that my web service is closing connections. Why is this
| happening? Can I increase the max pool size? How?
|
| thanks,
| Param
|
|



Re: urgent: connection pooling error

Postby Param R. » Sun, 14 Nov 2004 14:11:51 GMT

Where can I find a sample connection string to increase the pool size?

thanks!











Re: urgent: connection pooling error

Postby Param R. » Wed, 17 Nov 2004 08:42:11 GMT

This error never surfaced in .net 1.0. Any ideas? Ever since I upgraded to 
.net 1.1 sp1 it has started.

TIA!











Similar Threads:

1.connection in connection pool with pooling=false

I'm finding that even when pooling=false, a connection remains in my
connection pool connected to my database (it seems to quite quickly timeout
though - say 30 seconds).

My connection string:

    Initial Catalog=Benji_UnitTest;Data Source=.;Integrated
Security=SSPI;Pooling=false



Using this setting, I would expect that a new connection be created
everytime, and that when the SqlConnection is close()'d (i.e., returned to
the "pool") that the underlying database connection would be closed.

I also tried setting ";Connection Lifetime=1" in order to get the connection
to close quickly (as a worksround); this didn't seem to affect any change.

Am I misunderstanding something?



Thanks,

j


2.Help Requried on Connection Pooling [Urgent]

Hi ,

i have a requriment where i need to perform connection pooling through 
c#.net code .My database is Sybase.
Can any one forward me link or suggest me on how to start to write code for 
this.

Regards
Mani.

3.Problems in Connection pooling. Urgent

4.Problems in Connection pooling: Urgent

Hello All,

My windows application has a form that needs to display fresh data to the
user at short intervals (say every 10 seconds). For this purpose, I have
included a timer. On every timer tick, I perform the database related
operations to display the result to the user.
Note: Multiple instances of my application will be running at the same time
and hence the timer running in each instance and initiation database
operations.

With this approach, I started receiving errors like: Connection timed out.
The connection pool has reached its maximum size because every request to
the database opened and closed a connection. I changed the approach to:
Creating a single connection for the entire form so that all operations use
the same open connection. The connection is closed when the form closes.
Even then, I now get the following type of errors:

a) 8/11/2003 3:21:40 PM    SqlUtility   Execute   Error: Transaction
(Process ID 73) was deadlocked on lock resources with another process and
has been chosen as the deadlock victim. Rerun the transaction.
TimeTic Calling sp_ProductionTestBackgroundTask    at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior,
RunBehavior runBehavior, Boolean returnStream)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at IMD.OM.Database.SqlUtility.Execute(SqlParameter& prmOutParam,
SqlConnection cnnCommon) in
d:\khyatis\work\projects\imd\imdom\misc\sqlutility.cs:line 595
8/11/2003 3:21:40 PM    SC Status   Start NSC Monitor   Error:     at
OM.Database.SqlUtility.Execute(SqlParameter& prmOutParam, SqlConnection
cnnCommon) in d:\xyz\work\projects\\misc\sqlutility.cs:line 608
   at IMD.OM.SC.SCStatus.StartNSCMonitor(SqlConnection commonConnection) in
d:\xyz\work\projects\scstatus.cs:line 564System.Data.SqlClient.SqlException:
Transaction (Process ID 73) was deadlocked on lock resources with another
process and has been chosen as the deadlock victim. Rerun the transaction.
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
   at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
   at IMD.OM.Database.SqlUtility.Execute(SqlParameter& prmOutParam,
SqlConnection cnnCommon) in d:\xyz\work\projects\\misc\sqlutility.cs:line
595

I need to get rid of the above problem.

Regards,
Mithun







5.Leftover Connections in Connection Pool (connection leak)

This never happened before in .NET Framework 1.0 nor .NET Framework
1.1, but connection leak happens if you don't close the connection when
you use SqlTransaction. I would like to share this information with the
MS dev community.

We had this issue of SQL Server performing very poorly while running
our application. My colleague found out that connection leak was
happening whenever the .NET code executed transactions. So I created a
small console program that does a transaction like the following.

Imports System.Data
Imports System.Data.SqlClient

Module Module1

	Sub Main()

Begin:
		Dim Conn As SqlConnection = GetConnection()
		Conn.Open()
		Dim Trans As SqlTransaction =
Conn.BeginTransaction(IsolationLevel.ReadUncommitted)

		Dim Cmd As New SqlCommand("tblTest_ins", Trans.Connection, Trans)
		Cmd.CommandType = CommandType.StoredProcedure

		For i As Integer = 1 To 50
			Console.WriteLine("Executing stored proc. (" & i.ToString() & ")")
			Dim parTestCol As New SqlParameter()
			With parTestCol
				.ParameterName = "@TestCol"
				.Direction = ParameterDirection.Input
				.SqlDbType = SqlDbType.NVarChar
				.Size = 50
				.SqlValue = "TestValue " & DateTime.Now.ToString()
			End With

			Cmd.Parameters.Add(parTestCol)
			Cmd.ExecuteNonQuery()

			Cmd.Parameters.Clear()
		Next

		Trans.Commit()

		Console.WriteLine("Execution Completed")

		Dim Entry As ConsoleKeyInfo = Console.ReadKey()
		If Entry.Key = ConsoleKey.Y Then
			GoTo Begin
		Else
			Return
		End If
	End Sub

	Private Function GetConnection() As
System.Data.SqlClient.SqlConnection
		Dim Conn As New
SqlConnection("server=(local);database=Test;Pooling=true;user
id=sa;password=whatever;Application Name=HelloConnPool;connection
reset=true;")
		Return Conn
	End Function

End Module

I ran this code many times, and connection leak was happening. So I
added Conn.Close() right after Trans.Commit(), then the leak was gone.
Well, I could have done Trans.Connection.Close(), but the thing was
that right after the transaction was committed, Connection property was
null. So as we have a data layer that doesn't expose the underlying
connection, we had to define a variable as SqlConnection and hold onto
the reference to the connection from the transaction and the close it
after commit.

I hope I explained this issue well, but this never happened in .NET
Framework 1.1. We converted our code from 1.1 to 2.0, and didn't change
a thing, but this issue came out. I hope this will help people who
experience the same kind of issue. If you have any question, please
just post it here.

6. Pooled connection error

7. Trap "connection pool" errors [crosspost from .asp]

8. "General Network Error" and Connection Pooling



Return to dotnet framework

 

Who is online

Users browsing this forum: No registered users and 34 guest