Monday, October 26, 2009

DataReader and Dataset

In one of the project that I was working on there was a Time Out exception happened while navigating through lot of records. It was causing the whole application to crash. While examinig the application closely and running the sql profiler and using the below query to get all the processes that are active or getting created.

Query Analyzer:

EXEC SP_WHO2

SELECT [sql_handle],stmt_start,stmt_end,loginame,[program_name],hostname,* FROM MASTER..SYSPROCESSES WHERE [program_name]='.Net SqlClient Data Provider' ORDER BY SPID DESC

SELECT * FROM MASTER..SYSDATABASES
SYSDATABASES will give the database name that is being used.

SQL Profiler:

In the Sql profiler we can examine for which database and for what processes the queries are executed.

***********************************************************************************

While closely examining the code I found out that the datareader was cauing the issue. And also I noticed that the sp_reset_connection Stored procedure was not getting called after the datareader performed its operation.
Changing this to dataset really resolved the issue and unnecessary connection was not getting opened and also sp_reset_connection was getting called.

No comments:

Post a Comment