I have a web app that is running from a SQL Server 2005 database. Periodically, the app generates a timeout error, but if I run the command from management studio, it takes less than a second. Furthermore, the timeout error appears to happen randomly and does not occur with only a specific command.
My first guess was that maybe the database was locking due to a transaction. All my transactions are contained within a single stored procedure and follow the format
BEGIN TRY
BEGIN TRANSACTION
...
code
...
Commit
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION
DECLARE @msg VARCHAR(500)
DECLARE @severity INT
DECLARE @state INT
SET @severity= ERROR_SEVERITY()
SET @state=ERROR_STATE()
SET @msg = ERROR_MESSAGE()
RAISERROR(@msg,@severity,@state)
END CATCH
So, I set up the SQL Server PRofiler to see what was happennning. Unfortunately, I cannot recreate the error (it just occurs randomly and I can't just play with the program all day waiting for it to happen) so I have to rely on others to tell me when it occurs. One person gave me the time and when I checked it out on the profiler, it seemed to correspond to an Audit Logout with a duration of about 7.5 minutes. Does this sound like the cause of my issue? And if so, how can i fix it? I'm using the microsoft enterprise library for my database access so it handles all the opening and closing of connections for me.
Thanks in advance
My first guess was that maybe the database was locking due to a transaction. All my transactions are contained within a single stored procedure and follow the format
BEGIN TRY
BEGIN TRANSACTION
...
code
...
Commit
END TRY
BEGIN CATCH
IF @@TRANCOUNT > 0
ROLLBACK TRANSACTION
DECLARE @msg VARCHAR(500)
DECLARE @severity INT
DECLARE @state INT
SET @severity= ERROR_SEVERITY()
SET @state=ERROR_STATE()
SET @msg = ERROR_MESSAGE()
RAISERROR(@msg,@severity,@state)
END CATCH
So, I set up the SQL Server PRofiler to see what was happennning. Unfortunately, I cannot recreate the error (it just occurs randomly and I can't just play with the program all day waiting for it to happen) so I have to rely on others to tell me when it occurs. One person gave me the time and when I checked it out on the profiler, it seemed to correspond to an Audit Logout with a duration of about 7.5 minutes. Does this sound like the cause of my issue? And if so, how can i fix it? I'm using the microsoft enterprise library for my database access so it handles all the opening and closing of connections for me.
Thanks in advance