c# - Stored procedure times out when ran from code, but not from query tool -


I'm trying to understand why a stored procedure takes calls in the SQL Server Express Query window, but when I run the call code in the stored procedure in the query time out. We are using SQL Server 2008. I know it is difficult to say what is happening without looking at the stored procedure. I just hope this is a known issue.

  EXEC STORED_PROCEDURE_X '07 / 01/2010 SQL query that calls "STORED_PROCEDURE_X" and runs in 2 seconds in the SQL Server Express Query window:   < The code that says "STORED_PROCEDURE_X" and TIMES calls out: '07 / 31/2010 ', 0,' ',' true ',' ',' top 20 ' 

  SqlConnection connSQL = Faucet; SqlCommand sqlCmd = Faucet; SqlDataAdapter sqlDataAdpater = null; DataTable Return Data = Faucet; Try {ReturnData = new DataTable (); ConnSQL = new SqlConnection (sqlConnection); SqlCmd = New SqlCommand ("STORED_PROC_X", connSQL); If (connSQL.State == ConnectionState.Closed) {connSQL.Open (); } SqlCmd.CommandType = CommandType.StoredProcedure; SqlCmd.CommandTimeout = 600; SqlCmd.Parameters.Add ("StartDate", SqlDbType.NVarChar) .Value = "07/01/2010"; SqlCmd.Parameters.Add ("@AndDate", SqlDbType.NVarChar). Value = "07/31/2010"; SqlCmd.Parameters.Add ("@OuttyType", SqlDbType.Int). Value = "0"; SqlCmd.Parameters.Add ("@ SortBy", SqlDbType.NVarChar) .Value = ""; SqlCmd.Parameters.Add ("@ IsClaimDepartment", SqlDbType.NVarChar) .Value = "true"; SqlCmd.Parameters.Add ("@ IdsList", SqlDbType.NVarChar) .Value = ""; SqlCmd.Parameters.Add ("@ ReportType", SqlDbType.NVarChar). Value = "top 20"; SqlDataAdpater = New SqlDataAdapter (sqlCmd); SqlDataAdpater.Fill (returnData); If (connSQL.State == ConnectionState.Open) {connSQL.Close (); } Return withdrawal data; } Hold (Exception Pre) {LogErrorMessages ("ExecuteStoredProcedure", ex.Message); East; }  

Exception received:

  System.Data.SqlClient.SqlException: timeout time has expired. The timeout period has expired before the operation is completed or the server is not responding.  

Then, a stored proc is running which returned 30 records in I 00: 00 seconds management console but when I load it, I took about 40 seconds, more than the default 30 seconds timeout.

I simply modify the stored proc and run the alternate process again. .. Code and problem was resolved immediately without changing anything. I do not have much information about the source of this error, but at least this is pretty fast


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -