Comments are available to members only. Sign up or Log in to view these comments.
Main Topics
Browse All TopicsI asked this before but got side tracked and found a work around but not an answer. This was my original post:
http://www.experts-exchang
Here is my original question:
Is there a way to see how many SqlConnection's I have open (that I didn't close) while debugging my app? So by the time my app is done I want to check how many connections I still have open that I need to close. Can I use a trace or do I have to code something?
The problem I’m having has to do with Connection Pooling issues. I don’t think the connection is closed when I leave this function (below). I’m not trusting “CommandBehavior.CloseConn
http://codebetter.com/blog
http://codebetter.com/blog
http://forums.mysql.com/re
// The Function in Question:
public SqlDataReader GetRatesByPAGE (string PAGE, string vDataSource) {
SqlConnection cnn = new SqlConnection(GetConnectio
SqlCommand cmd = new SqlCommand("Refacts_GetBas
cmd.CommandType = CommandType.StoredProcedur
SqlParameter parmPAGE = new SqlParameter("@Page", SqlDbType.VarChar, 7);
parmPAGE.Value = PAGE;
cmd.Parameters.Add(parmPAG
cnn.Open();
SqlDataReader reader = cmd.ExecuteReader(CommandB
return reader;
}
Here is something I found that tracks the connections opening and closing. I implement by placing the handler event in a class that has the function (such as above) and in the function, after the cnn is created, I place the handler. But I'm not convinced it actually is doing what I think I want which is to accurately tell me if the cnn is still open or closed. It says it is but can I trust that?
// This is my reference
// http://msdn2.microsoft.com
// This is adding the handler
cnn.StateChange += new StateChangeEventHandler(On
// This is the handler event
protected static void OnStateChange(object sender, StateChangeEventArgs args) {
StreamWriter sWriter=new StreamWriter(@"C:\Inetpub\
sWriter.WriteLine("The current Connection state has changed from {0} to {1}.", args.OriginalState, args.CurrentState);
sWriter.Flush();
sWriter.Close();
}
I have my suspicions because I know if I try to close or dispose of my cnn before I return the reader then I get this error from the caller.
"Invalid attempt to HasRows when reader is closed."
That tells me that the reader can’t exist without a connection. I know that “CommandBehavior.CloseConn
Does anyone have any intimate knowledge/experience with this?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: cjm30305Posted on 2007-05-23 at 07:55:03ID: 19141998
Comments are available to members only. Sign up or Log in to view these comments.