日期:2014-05-17 浏览次数:20972 次
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();          
         }