Reputation: 2524
I have an application that simply opens an SqlConnection to a remote host. My code is something like this:
SqlConnection sc = new SqlConnection();
sc.ConnectionString = sConnectionString;
sc.Open();
I ran the application while my network monitoring tool is open. I noticed that there were 4 local ports opened that communicates with the 1433 port of the remote host. I am expecting that only 1 port will open. Why is this so?
Upvotes: 1
Views: 434
Reputation: 6962
If you have permissions to see the open database connections in the remote database server, compare this to the tcp/ip connections open in the machine hosting the application.
If the number of connections open on the database server match with the corresponding tcp/ip connections, you can be sure that there are multiple simultaneous connections open, and debug this further.
In SQL Server 2008, execute sp_who2
or open the Activity Monitor. You should be able to identify the connection sources from the results. In the application host use netstat -n
or other network monitoring tool.
Upvotes: 1
Reputation: 457
I am guessing that you haven't closed your sqlconnection and it has been opened continuously , try restarting the server and (try restarting your computer as well) . And use this code after you do your work. It happened to me before and this worked for me .
SqlConnection sc = new SqlConnection();
sc.ConnectionString = sConnectionString;
sc.Open();
// do you coding here
// complete all the operations related to this connection
//close the connection
sc.Close();
Upvotes: 1