We are using DAAB (Microsoft.ApplicationBlocks.Data) to execute stored
procedure from .NET But at times we get the following exception "Timeout
expired. The timeout period elapsed prior to completion of the operation or
the server is not responding".
Would appreciate immediate help.
Exception Information *********************************************
Exception Type: System.Data.SqlClient.SqlException Errors:
System.Data.SqlClient.SqlErrorCollection Class: 10 LineNumber: 0 Message:
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding. Number: -2 Procedure:
ConnectionRead (recv()). Server: State: 0 Source: .Net SqlClient Data
Provider TargetSite: System.Data.SqlClient.SqlDataReader
ExecuteReader(System.Data.CommandBehavior, System.Data.SqlClient.RunBehavior,
Boolean) HelpLink: NULL StackTrace Information
********************************************* at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior,
RunBehavior runBehavior, Boolean returnStream) at
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
at Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(SqlConnection
connection, SqlTransaction transaction, CommandType commandType, String
commandText, SqlParameter[] commandParameters, SqlConnectionOwnership
connectionOwnership) at
Microsoft.ApplicationBlocks.Data.SqlHelper.ExecuteReader(String
connectionString, CommandType commandType, String commandText, SqlParameter[]
commandParameters) at
TCOM.OSS.Providers.SQLProvider.Provider.CallStoredProc(String procedureName,
SqlParameter[]& sqlParameterList)
Check for blocking. Run sp_who2 to see what process it blocking another one.
Look at "blocks, avoiding" in SQL Server BOL.
Regards
Mike
Thanks a lot for the prompt answer. Actually, we are getting this error on
production and at times when no other heavy process is running.
Could it be because of the 'Timeout' settings in DAAB not working properly
or DAAB not handling connection management properly.
Thanks & Best Regards,
Sachin
*** Sent via Developersdex http://www.developersdex.com ***
thanks.
-MJ
Sachin Surana wrote:
> *Hi All,
> SqlParameter[]& sqlParameterList) *
--
MBeaudreau
------------------------------------------------------------------------
Posted via http://www.codecomments.com
------------------------------------------------------------------------
Any help is greatly appreciated.
thanks,
-MJ
Sachin Surana wrote:
> *Hi All,
Cheers,
Sachin
Timeout expired. The timeout period elapsed prior to completion of the
operation or the server is not responding. (.Net SqlClient Data Provider)
----------------------------------------
For help, click: http://go.microsoft.com/fwlink?
ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=-2&LinkId=20476
----------------------------------------
Error Number: -2
Severity: 11
State: 0
----------------------------------------
Program Location:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.
ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Connect(Boolean& useFailoverPartner,
Boolean& failoverDemandDone, String host, String failoverPartner, String
protocol, SqlInternalConnectionTds connHandler, Int64 timerExpire, Boolean
encrypt, Boolean integratedSecurity, SqlConnection owningObject, Boolean
aliasLookup)
at System.Data.SqlClient.SqlInternalConnectionTds.
OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString
connectionOptions, String newPassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..
ctor(SqlConnectionString connectionOptions, Object providerInfo, String
newPassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.
CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo,
DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.
CreateNonPooledConnection(DbConnection owningConnection,
DbConnectionPoolGroup poolGroup)
at System.Data.ProviderBase.DbConnectionFactory.
GetConnection(DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionClosed.
OpenConnection(DbConnection outerConnection, DbConnectionFactory
connectionFactory)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.SqlServer.Management.UI.VSIntegration.ObjectExplorer.
ObjectExplorer.ValidateConnection(UIConnectionInfo ci, IServerType server)
at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.
ConnectionThreadUser()
The following code will connect the sql adapter and sql command, applying
this will solve the timeout exception
DbConn.Open()
Dim DbCmd As New SqlClient.SqlDataAdapter
Dim cmd As New SqlCommand(sSQL, DbConn)
cmd.CommandTimeout = 250
DbCmd.SelectCommand = cmd
Dim Dt As New DataTable
DbCmd.Fill(Dt)
DbConn.Close()
Return Dt
Same logic can be applied to oledb command also
Dim DbCmd As New OleDb.OleDbDataAdapter
Dim cmd As New OleDb.OleDbCommand(sSQL, OraConn)
cmd.CommandTimeout = 250
DbCmd.SelectCommand = cmd
Dim Dt As New DataTable
DbCmd.Fill(Dt)
DbConn.Close()
Return Dt
Happy Programming
if u r not having any parameters then set to ''.
Linchi
If you want better answer, you need to provide more details first.
--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se
Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx