读书人

新手问【Timeout expired】有关问题

发布时间: 2012-09-14 11:53:44 作者: rapoo

新手问【Timeout expired】问题

C# code
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();//[color=#FF0000]这里有问题[/color]                        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.的问题,为什么呢

[解决办法]
command.CommandTimeout = 0;



[解决办法]
getxfjdkc 是不是存储过程
是存储过程的话,你这种写法是错误的。

读书人网 >C#

热点推荐