TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
tomar_prashant09
NA
3
0
Conection remains open on MS SQL Server 2000
Mar 24 2004 1:41 AM
I am using .NET SDK version 1.1. I have executed the following C# code (I have used namespace System.Data.SqlClient as database server is MS SQL Server 2000) : // start of code string connString = "Server=TestServer; Database=TestData; uid=tester; pwd=testpass"; using (SqlConnection conn = new SqlConnection (connString )) { conn.Open (); MessageBox.Show ("Connection is open.", "Connection status"); } if (conn.State == ConnectionState.Closed) { MessageBox.Show ("Connection to server closed.", "Connection status"); } // end of code I have open the "SQL Profiler" application of "MS SQL Server" and start the "Trace" window to monitor the Audit Login and Audit Logout traces on the SQL Server end. This is to check the status of the connection at SQL Server end. Observation: 1. When executed the above C# code, the application displays message indicating connection is open. The "SQL Profiler Trace" window displays two "Audit Login" traces indicating two connections are made to SQL Server. 2. Dismissed the message box by clicking OK button. The application then executes conn.Close() method and displays next message as "Connection to Server closed". 3. But even though the application has called the conn.Close() method, SQL Profiler did not display "Audit Logout" trace. This indicates that at SQL Server end, the connections are still open. 4. When exited the application, then only SQL Profiler displayed two "Audit Logout" traces indicating both connections are closed at Server end. I have following queries w.r.t. above observations: 1. In first place why two connections are open at SQL Server instead of only one. 2. Even if the conn.Close() method is executed in application, both connections are remained open at SQL Server. Why the connections are not closed at Server end? Is this the connection pooling that ADO.NET does? 3. What I need to do in code to make sure that the connection will be actually closed at SQL Server end whenever I call the conn.Close() method in my code? Please answer. Thanks and regards, Prashant.
Reply
Answers (
1
)
Error connecting to an oracle database using Microsoft's data provider for oracle
How to use TypedDataSet