MyConnection.Open() hangs after period of time...?

dankarmy

New member
Joined
Jan 23, 2005
Messages
3
Programming Experience
3-5
HI,

Ive been debugging my app for hours and I can't figure out why it is doing this, I have wrote a VB app that processes messages from a database and sends them out as emails every 3 seconds.

At some point in my program I write back to the database if the send was successful/failure. On the 138 time of access it hangs! every time its 138.

Im being careful to clean out my connection:

Dim sSqlConnection As SqlConnection



Try

sSqlConnection = New SqlConnection(sConnection)

Dim sCommand As New SqlCommand(sStoredProc, sSqlConnection)

sCommand.CommandType = CommandType.StoredProcedure

If Status = 1 Then

'//Success

sCommand.Parameters.Add("@pmSuccess", 1)

Else

sCommand.Parameters.Add("@pmFailure", 1)

End If

sCommand.Parameters.Add("@pmAgentID", AgentID)

(hangs at this point) -> sSqlConnection.Open()

sCommand.ExecuteNonQuery()

Catch ex As Exception

Finally

If sSqlConnection.State = ConnectionState.Open Then

sSqlConnection.Close()

End If

End Try


It falls into the Catch Block but with NO error message, then the program just hangs.

Has anyone heard of this bizzare thing? Or anyone have any hunches on why it could be doing this/

Thanks

J
 

Administrator

VB.NET Forum Admin
Joined
Jun 3, 2004
Messages
1,461
Programming Experience
10+
You don't have any code to show the ex.Message. Have you tried populating your Catch handling so it identifies the message?

Try setting a timeout as well.
 

dankarmy

New member
Joined
Jan 23, 2005
Messages
3
Programming Experience
3-5
Ok,

heres the error message I get

Timeout expired. The Timeout peiod elapsed prior to obtaining a connection from the pool. This may have occured because all poooled connections were in use and max pool size was reached.

Ive done some research and it seems to be a connection pooling problem. I dont understand why I have to increased my pool tho? Im closing my connection and everything.

Any help would be great

John
 

dankarmy

New member
Joined
Jan 23, 2005
Messages
3
Programming Experience
3-5
Ok,

I think I've found my problem, I wasn't closing the connectinon of another process I was doing so I assume I used up all the available connections in the pool.

Thanks for your help tho

J
 
Top Bottom