我的一个Sql语句在查询分析器中执行的时间是3分钟,但是在程序就打开却出现错误:Server Error in '/' Application.
--------------------------------------------------------------------------------Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.Source Error: 部分程序如下: Dim ConnStr As String
ConnStr = System.Configuration.ConfigurationSettings.AppSettings("kingseer_dbConnectionString").ToString
Dim MyConnection As SqlClient.SqlConnection
MyConnection = New SqlClient.SqlConnection(ConnStr)
MyConnection.Open()
string sql="select * from table"
Dim dsdataSet As New DataSet1() Dim daOrders As New Data.SqlClient.SqlDataAdapter(sql, MyConnection)
daOrders.Fill(dsdataSet, "t_biao_cnskb") '使用“报表引擎”对象模型将填充的数据集,传递给报表
oRpt.SetDataSource(dsdataSet)
CrystalReportViewer1.ReportSource = oRpt请回答,谢谢!
--------------------------------------------------------------------------------Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.Source Error: 部分程序如下: Dim ConnStr As String
ConnStr = System.Configuration.ConfigurationSettings.AppSettings("kingseer_dbConnectionString").ToString
Dim MyConnection As SqlClient.SqlConnection
MyConnection = New SqlClient.SqlConnection(ConnStr)
MyConnection.Open()
string sql="select * from table"
Dim dsdataSet As New DataSet1() Dim daOrders As New Data.SqlClient.SqlDataAdapter(sql, MyConnection)
daOrders.Fill(dsdataSet, "t_biao_cnskb") '使用“报表引擎”对象模型将填充的数据集,传递给报表
oRpt.SetDataSource(dsdataSet)
CrystalReportViewer1.ReportSource = oRpt请回答,谢谢!
解决方案 »
- 关于判断汉字为字母的问题
- 新手上路,请教各位达人关于伪静态地址,或者地址重写的办法,折腾好几天了,希望有人救救我呀,50分求结果
- 大家看看这个项目代码生成器好用不?直接生成可以用的BS项目
- aspx如何过滤表单里的sql特殊字符,例如单引号,分号?
- 关于域名转换问题: 高手指点..
- 请问各位高手,怎样在程序里控制TableCell在TableRow里的显示格式
- 如何用datalist取出特定字段的数据?
- 浏览器的缓存问题
- 出现了一个前所未有的错误 没见过额 高人指教3Q
- CrystalReport come on!
- html文件也能传参数吗?就是sample.html?id=11。为什么要这样做?
- WCF上传文件怎样与.net结合
如果你的数据太大,可以用分页,每次返回一部分数据;
尽量不要用 select *,用什么字段写什么字段;
如果非要一次返回,设下 SqlCommand.CommandTimeout
daOrders.Fill(dsdataSet, "t_biao_cnskb")
Dim ConnStr As String
ConnStr = System.Configuration.ConfigurationSettings.AppSettings("kingseer_dbConnectionString").ToString
Dim MyConnection As SqlClient.SqlConnection MyConnection = New SqlClient.SqlConnection(ConnStr) MyConnection.Open()
MyConnection.ConnectionTimeout = 500这么写不对。
/// <summary>
/// 执行查询语句,返回DataSet
/// </summary>
/// <param name = "SQLString">查询语句</param>
/// <returns>DataSet</returns>
public static DataSet Query(string SQLString)
{
using (SqlConnection connection = new SqlConnection(connectionString))
{
DataSet ds = new DataSet();
try
{
connection.Open();
//SQLString = ClearSQLString(SQLString);
SqlDataAdapter command = new SqlDataAdapter(SQLString,connection);
command.SelectCommand.CommandTimeout = 300;//300s
command.Fill(ds,"ds");
}
catch(System.Data.SqlClient.SqlException ex)
{
//Utility.Logs.WriteLogFile(ex,SQLString);
throw new Exception(ex.Message);
}
finally
{
connection.Close();
connection.Dispose();
}
return ds;
}
}