问题描述
我在Sql数据库中有一个表,在表中有超过40,000条记录...,
现在在我的网站的一页上,
i希望根据动态查询显示该数据(根据条件添加多个查询),然后将此查询的所有结果返回给DataTable和然后把它放入GRIDVIew,
现在我的问题是,当我想一次显示所有结果然后它给出错误这样的..
I have a table in Sql Database And in table there in more then 40,000 record...,
Now on one page of my site,,
i want to show that data according to Dynamic query(add Multiple Query According to condition),and then return all result of this query to DataTable and Then Put It into GRIDVIew,
Now My problem is, when i want to show all result at a time then it gives error Like this..
Timeout expired. The timeout period elapsed prior to complete
或查询无效返回 ,,,
当我根据某些条件获取数据然后它返回完美数据(当数据表的结果低时表示工作正常......),
这是我的代码:
or Query Return Nothing,,,
And when i take data according to some condition then It Return perfect data(Means When Result of data table is low then it work fine...),
This is My Code:
StringBuilder strSql2 = new StringBuilder();
strSql2.Append("SELECT t.id, t.year,t.courtname,t.partyname,t.itano,t.favour,t.sectionno, STUFF((SELECT ' ' + s.sitentionno ,' ' + s.subjudgements,' ' + s.page , ' ' FROM tblJudgements s WHERE s.partyname = t.partyname FOR XML PATH('')),1,0,'') AS Citation FROM tblJudgements AS t where t.categoryname='Direct Taxes' ");
if (txtWordAd.Text != "")
{
string keywords = txtWordAd.Text;
if (!string.IsNullOrEmpty(keywords))
{
string[] words = keywords.Split(' ');
for (int i = 0; i < words.Length; i++)
{
if (i == 0)
{
strSql2.Append(" and ( t.judgement like '%[^a-z]" + words[i].ToString().Trim() + "[^a-z]%' ) ");
}
else
{
strSql2.Append(" and judgement like '%[^a-z]" + words[i].ToString().Trim() + "[^a-z]%'");
}
}
}
}
if (txtDateFromAd.Text != "" && txtDateToAd.Text != "")
{
strSql2.Append(" and (dateofjudgement between '" + txtDateFromAd.Text + "' and '" + txtDateToAd.Text + "' ) ");
}
SqlDataAdapter adp4 = new SqlDataAdapter(strSql2.ToString(), strConn);
adp4.Fill(dt);
GridJudgementAdvanced1.DataSource = dt;
GridJudgementAdvanced1.DataBind();
}
i也可以尝试:adp4.SelectCommand.CommandTimeout = 120 ;
但它不起作用,
i一次应用于GridView 20记录,但是问题是查询返回所有40000记录到数据表而这耗费了这么多时间,完成一个查询(过程...),
所以在那种情况下我能做什么?做???????
Plz帮助..
我也在这里找到同样的问题,但没有解决方案..
[]
[]
[]
i also try :adp4.SelectCommand.CommandTimeout = 120;
but it not work,,
i apply pagging to GridView 20 record at a time, But Problem is Query Return All 40000 record to datatable And this Consume So much Time, to complete one Query(Process...),
So in that Situation What can i Do ???????
Plz help..
I Also Find Same Problem Here,But There is no solution..
[^]
How to resolve Time out Error in Classic ASP[^]
Timeout expired sql server problem[^]
推荐答案
select * from people order by lastname,firstname offset 0 rows fetch next 20 rows only
检索接下来的20行
Retrieves next 20 rows
select * from people order by lastname,firstname offset 20 rows fetch next 20 rows only
那说,我觉得任何阙在一个在线业务应用程序中,返回与查询一样多的行应该应用其他选择条件,以大大减少检索的行数。您的用户可能不希望一次分页40,000行20。这是下一步的2,000次点击。让用户花时间让他们使用其他选择标准来选择他们真正需要看到的那几行时,会更加考虑。
That said, I think that any query in an online business application that returns as many rows as your query should have additional selection criteria applied to greatly reduce the number of rows retrieved. Your user probably does not want to page through 40,000 rows 20 at a time. That is 2,000 clicks on Next. It would be more considerate of your user's time to let them use additional selection criteria to select only those few rows that they really need to see.
这篇关于超时已过期。 complet之前经过的超时时间...错误Occure的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!