Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, August 1, 2013 5:23 PM
HI,
I am getting SQL connection timeout error while storing records in tempdb in my C# code. I have used command.CommandTimeout = 0 but still getting time out error .
The no.of records it has store is around one million . Is there any max limit of time the connection will be active after that it will be disconnected?
Actual error :
System.Data.SqlClient.SqlException (0x80131904):
A transport-level error has occurred when receiving results from the server.
(provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
> System.ComponentModel.Win32Exception (0x80004005): The semaphore
timeout period has expired
Thanks,
Siva
All replies (3)
Friday, August 2, 2013 8:19 AM âś…Answered
(provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
I never had a "semaphore timeout" issue; but here it is someone with the same issue, which seems to be solved: http://stackoverflow.com/questions/551282/semaphore-timeout-period
Olaf Helper
Thursday, August 1, 2013 5:52 PM
I am getting SQL connection timeout error while storing records in tempdb in my C# code. I have used command.CommandTimeout = 0
Hello Siva,
You mix up ConnectionTimeout with CommandTimeout; if you change the CommandTimeout value it don't change anything for the ConnectionTime.
So what timeout error do you get, for the Connection or for the Command?
Olaf Helper
Friday, August 2, 2013 7:08 AM
Sorry for the confusion.
getting below error:
System.Data.SqlClient.SqlException (0x80131904):
A transport-level error has occurred when receiving results from the server.
(provider: TCP Provider, error: 0 - The semaphore timeout period has expired.)
> System.ComponentModel.Win32Exception (0x80004005): The semaphore
timeout period has expired
code :
string connectionString = ConfigurationManager.ConnectionStrings["DBconnection"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connectionString))
{
SqlCommand commandCreateTemp = new SqlCommand("********");
commandCreateTemp.CommandTimeout = 0;
try
{
commandCreateTemp.Connection = conn;
commandCreateTemp.Connection.Open();
commandCreateTemp.ExecuteNonQuery();
}
foreach (Item result in dictionary.Values)
{
//for every item in the dictionary you insert the data into the table
SqlCommand command = new SqlCommand("INSERT INTO ##GlobalTemp (Columns) VALUES (****)");
count++;
command.CommandTimeout = 0;
try
{
command.Connection = conn;
command.CommandType = CommandType.Text;
command.Connection = conn;
command.Parameters.AddWithValue("**");
}
catch()
{}
}