Hi everyone,

This is the error i am getting when i try to do SqlCommand.ExecuteNonQuery(). My application runs on multiple threads and constantly opens, executes and close connection. This error i am getting after running the application for some time.

Error:
System.Data.SqlClient.SqlException: A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

Thanks,
Raymond.

Is there a chance that your SqlCommand or the corresponding SqlConnection is shared and used by multiple threads and one of them might have closed the connection (socket/handle)?

If the application uses one connection from multiple threads then, If one thread closed the connection, and another tried to use it it could generate this error.

You still need to go through the other steps - check the
logs, check the network connectivity, etc.

No i have checked properly each thread uses its own connection and command and they are closed and disposed after using them.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.