新手问【Timeout expired】问题

Bottle 2012-09-01 04:27:57
using (SqlConnection connection = new SqlConnection(WebConfigurationManager.ConnectionStrings["dbconnection"].ConnectionString))
{
connection.Open();
SqlCommand com = new SqlCommand(strSQL, connection);
com.CommandType = CommandType.Text;
SqlDataReader reader = com.ExecuteReader();
if(reader.Read())
{
nd = reader["bzjhnd"].ToString();
jb = reader["bzjhjb"].ToString();
}else{
//没有找到符合要求的内容,返回
reader.Close();
return "-1";

}
reader.Close();
//重新赋值SQL语句
strSQL = "Exec getxfjdkc @Tempxh='" + userName + "',@nd='" + nd + "',@jb='" + jb + "'";
SqlCommand command = new SqlCommand(strSQL, connection);
command.CommandType = CommandType.Text;

reader = command.ExecuteReader();//这里有问题

while (reader.Read())
{
ResultIfo resultIfo = new ResultIfo();
resultIfo.SClass = reader["kcdlmc"].ToString();
resultIfo.SCode = reader["kcbm"].ToString();
resultIfo.Subject = reader["kcmc"].ToString();
resultIfo.Point = reader["xf"].ToString();
resultIfo.Result = reader["cj"].ToString();
resultIfo.InsSCode = reader["tdkcbm"].ToString();
resultIfo.InsSubject = reader["tdkcmc"].ToString();
resultIfo.InsPoint = reader["tdxf"].ToString();
resultIfo.InsResult = reader["tdcj"].ToString();

list.Add(resultIfo);
}
reader.Close();
}

请教一下上面的程序运行到 reader = command.ExecuteReader()的时候就会出现Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.的问题,为什么呢
...全文
203 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Bottle 2012-09-01
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 taomanman 的回复:]

getxfjdkc 是不是存储过程
是存储过程的话,你这种写法是错误的。
[/Quote]好吧,查到了,看来这是一个大问题哈,谢谢咯~具体找度娘去
Bottle 2012-09-01
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

getxfjdkc 是不是存储过程
是存储过程的话,你这种写法是错误的。
[/Quote]是存储过程,那应该怎么写呢,求教
暖枫无敌 2012-09-01
  • 打赏
  • 举报
回复
getxfjdkc 是不是存储过程
是存储过程的话,你这种写法是错误的。
Bottle 2012-09-01
  • 打赏
  • 举报
回复
调试执行第一个reader = com.ExecuteReader()没有问题,可是执行到第二个就弹到了网页的界面,然后网页一直在那刷新的样子
Bottle 2012-09-01
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 的回复:]

command.CommandTimeout = 0;
[/Quote]可是我这么设置了之后程序会一直执行,可是没有结果,在执行第一个的时候就不会出现这样的情况啊
SocketUpEx 2012-09-01
  • 打赏
  • 举报
回复
command.CommandTimeout = 0;


Bottle 2012-09-01
  • 打赏
  • 举报
回复
自己顶起

111,094

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧