Click here to Skip to main content
15,900,110 members
Home / Discussions / C#
   

C#

 
AnswerRe: Dataset/DataTable with DataGrid (local database only!) Pin
Private_Void19-Dec-06 7:43
Private_Void19-Dec-06 7:43 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Blubbo19-Dec-06 7:49
Blubbo19-Dec-06 7:49 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Private_Void19-Dec-06 8:39
Private_Void19-Dec-06 8:39 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Blubbo19-Dec-06 8:53
Blubbo19-Dec-06 8:53 
GeneralRe: Dataset/DataTable with DataGrid (local database only!) Pin
Private_Void19-Dec-06 9:47
Private_Void19-Dec-06 9:47 
QuestionDataGridView and new rows Pin
Wjousts19-Dec-06 3:25
Wjousts19-Dec-06 3:25 
AnswerRe: DataGridView and new rows Pin
Lisa Jorgensen23-Dec-06 16:18
Lisa Jorgensen23-Dec-06 16:18 
QuestionInconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 3:16
Jason Pease19-Dec-06 3:16 
I'm not sure if anyone will be able to help me with this problem without actually debugging the code, but I thought I'd give it a shot.

Here's the situation. I have a fairly mature and stable C#/ASP.NET application that I inherited a few years back. I'm familiar with nearly all of the code, but there are few classes here and there that I've never had to deal with; I know they work and that's it.

Late last night we came across a bug in which connections were getting leaked until the pool was saturated with the default 100 connections. It turned out that the connections were getting orphaned in a class that hasn't been touched in about five years. As strange as that is, the part that I really can't explain is that the method is called an several places in the application and it works correctly. However, when it is called in a page that was recently added to the application it leaks connections like a siv.

If it can help, here's the offending method (underscores added for legibility).

<br />
public int GetUserID(String UserName) <br />
{<br />
________// Create Instance of Connection and Command Object<br />
________SqlConnection myConnection = new SqlConnection(ConfigurationSettings.AppSettings["connectionStringUSR"]);<br />
________SqlCommand myCommand = new SqlCommand("GetSingleUserID", myConnection);<br />
<br />
________// Mark the Command as a SPROC<br />
________myCommand.CommandType = CommandType.StoredProcedure;<br />
<br />
________// Add Parameters to SPROC<br />
________SqlParameter parameterEmail = new SqlParameter("@Email", SqlDbType.NVarChar, 100);<br />
________parameterEmail.Value = UserName;<br />
________myCommand.Parameters.Add(parameterEmail);<br />
<br />
<br />
________if ((parameterEmail.Value != null) && (parameterEmail.Value != System.DBNull.Value)) <br />
________{<br />
________________// Open the database connection and execute the command<br />
________________myConnection.Open();<br />
<br />
________________SqlDataReader dr = myCommand.ExecuteReader(CommandBehavior.CloseConnection);<br />
________________if(dr.Read()==true)<br />
________________{<br />
________________________if(dr.IsDBNull(0))<br />
________________________________return -1;<br />
________________________else<br />
________________________________return dr.GetInt32(0);<br />
________________}<br />
________________else<br />
________________{<br />
________________________return -1;<br />
________________}<br />
________}<br />
________else<br />
________{<br />
________________return -1;<br />
________}<br />
}<br />
<br />


The myConnection.Close() is missing, but the CommandBehavior is set to CloseConnection so it should be getting closed correctly.

I am at a complete loss why this code would behave different based on what on what's below it on the stack, what in the session, or what's in some static variable, but that seems to be the case.

If anyone can help me figure this out I'll owe you dinner.

Thanks, Jason
AnswerRe: Inconsistent Connection Pooling Behavior Pin
althamda19-Dec-06 3:23
althamda19-Dec-06 3:23 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 3:32
Jason Pease19-Dec-06 3:32 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
althamda19-Dec-06 3:45
althamda19-Dec-06 3:45 
AnswerRe: Inconsistent Connection Pooling Behavior Pin
Guffa19-Dec-06 4:12
Guffa19-Dec-06 4:12 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 5:03
Jason Pease19-Dec-06 5:03 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Guffa19-Dec-06 5:13
Guffa19-Dec-06 5:13 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Jason Pease19-Dec-06 5:31
Jason Pease19-Dec-06 5:31 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
althamda19-Dec-06 5:39
althamda19-Dec-06 5:39 
GeneralRe: Inconsistent Connection Pooling Behavior Pin
Guffa19-Dec-06 5:42
Guffa19-Dec-06 5:42 
AnswerRe: Inconsistent Connection Pooling Behavior Pin
Pete O'Hanlon19-Dec-06 10:47
mvePete O'Hanlon19-Dec-06 10:47 
QuestionSmart Card Library (scardssplib) Help Pin
s.jahangiri19-Dec-06 2:46
s.jahangiri19-Dec-06 2:46 
Questionalthamda Pin
nima136319-Dec-06 2:44
nima136319-Dec-06 2:44 
AnswerRe: althamda Pin
althamda19-Dec-06 2:57
althamda19-Dec-06 2:57 
QuestionForms Pin
quiteSmart19-Dec-06 2:36
quiteSmart19-Dec-06 2:36 
AnswerRe: Forms Pin
netJP12L19-Dec-06 2:57
netJP12L19-Dec-06 2:57 
Questionalthamda thanks a lot Pin
nima136319-Dec-06 2:33
nima136319-Dec-06 2:33 
AnswerRe: althamda thanks a lot Pin
althamda19-Dec-06 2:36
althamda19-Dec-06 2:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.