C# “Asp.net web表单”;“等待操作超时”;

C# “Asp.net web表单”;“等待操作超时”;,c#,asp.net,tsql,connection-timeout,C#,Asp.net,Tsql,Connection Timeout,我有一个web表单,用于从报表服务器检索数据。我没有在该服务器中查询的表上创建索引的权限,而且查询的文本查找速度非常非常慢。我试着在查询中尽我所能进行优化,但是速度太慢了。所以我需要找到一种方法来避免网页本身超时。我已经回顾了几个类似的问题,我设置了一个疯狂的高连接超时,但我仍然在点击按钮时得到等待操作超时。超时发生在30秒后,即使我设置了如此高的连接超时。我不知道这是否是web配置,但我没有使用webconfig中定义的连接字符串,只是codebehind中的这个字符串。在SSMS中,查询不会

我有一个web表单,用于从报表服务器检索数据。我没有在该服务器中查询的表上创建索引的权限,而且查询的文本查找速度非常非常慢。我试着在查询中尽我所能进行优化,但是速度太慢了。所以我需要找到一种方法来避免网页本身超时。我已经回顾了几个类似的问题,我设置了一个疯狂的高连接超时,但我仍然在点击按钮时得到等待操作超时。超时发生在30秒后,即使我设置了如此高的连接超时。我不知道这是否是web配置,但我没有使用webconfig中定义的连接字符串,只是codebehind中的这个字符串。在SSMS中,查询不会超时,只有在从webform访问数据时才会超时(从技术上讲,webform在连接字符串中使用我的登录凭据,因此没有权限问题,其他部分运行正常)。还有其他地方需要增加页面的超时吗

连接字符串(出于隐私考虑,未使用/pw x'ed):

查询超时,如果有帮助:

 protected void btnSearchFeedback_Click(object sender, EventArgs e)
    {
        con.Open();
        SqlDataAdapter sdaFeedBack = new SqlDataAdapter("SELECT CTIR.portion_ID, IB.Item_ID as [Item ID], CTIR.Item_DBkey as [Item DB Key], CTIR.Feedback as [Feedback], CTA.date as [Date],CTA.Candidate_ID as [Candidate ID] FROM Canxxxxxxx CTIR WITH (NOLOCK) left join Ixxxxx IB WITH (NOLOCK) ON CTIR.xxxxx = IB.xxxxx left join Cxxxxxx CTA WITH (NOLOCK) ON CTxxxxxx = CTxxxxxxx where (ctir.portion_id in (" + portionIDTextBox.Text + ") ) AND (len(CTIR.Feedback) > 0) and CTA.Date  > '2015-02-01 00:00:00.000' order by [Date]", con);
        DataSet dtFeedBack = new DataSet();
        sdaFeedBack.Fill(dtFeedBack);
        ViewState["dtFeedback"] = dtFeedBack;
        rptFeedBack.DataSource = dtFeedBack;
        rptFeedBack.DataBind();
        con.Close();
    }
为了安全起见,再次用x标出了表名。因此,我正在尝试查看是否有其他位置需要将连接超时设置为更高的数字,以避免“应用程序“/”中的服务器错误。等待操作超时”,或者这是需要在服务器端处理的问题

这就是确切的错误:

“/”应用程序中出现服务器错误。 等待操作超时 描述:执行当前web请求期间发生未处理的异常。请查看堆栈跟踪以了解有关错误的更多信息以及错误在代码中的起源

异常详细信息:System.ComponentModel.Win32异常:等待操作超时

堆栈跟踪: [Win32Exception(0x80004005):等待操作超时]

[SqlException(0x80131904):超时已过期。操作完成前已过超时时间,或者服务器未响应。] System.Data.SqlClient.SqlConnection.OnError(SqlException异常,布尔breakConnection,Action
1 wrapCloseInAction)+2434922
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException异常,布尔断开连接,操作
1 wrapCloseInAction)+5736592 System.Data.SqlClient.TdsParser.throweexception和warning(TdsParserStateObject stateObj,布尔调用者连接锁,布尔异步关闭)+285 System.Data.SqlClient.TdsParser.TryRun(RunBehavior RunBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean&dataReady)+3731 System.Data.SqlClient.SqlDataReader.TrySetMetaData(_-SqlMetaDataSet-metaData,Boolean-moreInfo)+198 System.Data.SqlClient.TdsParser.TryRun(RunBehavior RunBehavior,SqlCommand cmdHandler,SqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj,Boolean&dataReady)+2852 System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()+58 System.Data.SqlClient.SqlDataReader.get_MetaData()+89 System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds、RunBehavior、String ResetOptions String)+379 System.Data.SqlClient.SqlCommand.RunExecuteReaderDS(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、Boolean async、Int32超时、任务与任务、Boolean asyncWrite、SqlDataReader ds、Boolean describeParameterEncryptionRequest)+2026 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior、RunBehavior RunBehavior、Boolean returnStream、String方法、TaskCompletionSource`1完成、Int32超时、任务和任务、Boolean asyncWrite)+375 System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior,RunBehavior RunBehavior,Boolean returnStream,String方法)+53 System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior,String方法)+240 System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior)+41 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior)+12 System.Data.Common.DbDataAdapter.FillInternal(数据集数据集,数据表[]数据表,Int32 StartRecords,Int32 maxRecords,字符串srcTable,IDbCommand命令,CommandBehavior)+139 System.Data.Common.DbDataAdapter.Fill(数据集数据集、Int32 startRecord、Int32 maxRecords、字符串srcTable、IDbCommand命令、CommandBehavior)+136 System.Data.Common.DbDataAdapter.Fill(数据集)+88 FeedBackForm.btn搜索反馈\在C:\Users\mfelchlin\Documents\visualstudio 2015\WebSites\devFormsSite\FeedBackForm.aspx.cs:27中单击(对象发送者,事件参数e) System.Web.UI.WebControls.Button.OnClick(EventArgs e)+9696694 System.Web.UI.WebControl.Button.RaisePostBackEvent(String eventArgument)+204 System.Web.UI.WebControl.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)+12 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl,String eventArgument)+15 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)+35 System.Web.UI.Page.ProcessRequestMain(布尔includeStagesBeforeAsyncPoint,布尔includeStagesAfterAsyncPoint)+1639

在连接上设置超时将确定等待连接打开的时间,而不是等待命令执行的时间


在连接上设置超时值决定了等待连接打开的时间,而不是等待命令执行的时间。

我发现很难相信X'ing out您的表名会提高安全性。表名是否为敏感数据?无论如何,我发现您更可能需要提高查询性能,而不是增加超时。此外,您没有正确处理对象。既然你没有使用参数
 protected void btnSearchFeedback_Click(object sender, EventArgs e)
    {
        con.Open();
        SqlDataAdapter sdaFeedBack = new SqlDataAdapter("SELECT CTIR.portion_ID, IB.Item_ID as [Item ID], CTIR.Item_DBkey as [Item DB Key], CTIR.Feedback as [Feedback], CTA.date as [Date],CTA.Candidate_ID as [Candidate ID] FROM Canxxxxxxx CTIR WITH (NOLOCK) left join Ixxxxx IB WITH (NOLOCK) ON CTIR.xxxxx = IB.xxxxx left join Cxxxxxx CTA WITH (NOLOCK) ON CTxxxxxx = CTxxxxxxx where (ctir.portion_id in (" + portionIDTextBox.Text + ") ) AND (len(CTIR.Feedback) > 0) and CTA.Date  > '2015-02-01 00:00:00.000' order by [Date]", con);
        DataSet dtFeedBack = new DataSet();
        sdaFeedBack.Fill(dtFeedBack);
        ViewState["dtFeedback"] = dtFeedBack;
        rptFeedBack.DataSource = dtFeedBack;
        rptFeedBack.DataBind();
        con.Close();
    }
sdaFeedBack.SelectCommand.CommandTimeout=120; //or some other number of seconds.