2017-01-16 11 views
-3
namespace BusinessLayer 
{ 
    public class StudentBusinessLayer 
    { 
     public List<Student> getStudents(string storedProcedure) 
     { 
      using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString)) 
      { 
       List<Student> students = new List<Student>(); 
       SqlCommand comm = new SqlCommand(storedProcedure, conn); 
       comm.CommandType = CommandType.StoredProcedure; 
       conn.Open(); 
       SqlDataReader rdr = comm.ExecuteReader(); 
       while (rdr.Read()) 
       { 
        Student s = new Student(); 
        s.id = Convert.ToInt32(rdr["id"]); 
        s.Name = rdr["Name"].ToString(); 
        s.TotalMarks = Convert.ToInt32(rdr["TotalMarks"]); 

        students.Add(s); 
       } 
       return students; 
      } 
     } 
    } 
} 

enter image description hereC#の - 一貫性のないアクセシビリティ:戻り値の型の一覧は

+0

あなたは今までそれをGoogleで検索していますか?それはGoogleの最初の結果、 – esiprogrammer

答えて

2

あなたのStudentクラスがないpublic、それはpublicあなたのエラーを修正するために行うことであると思われる方法よりも少ないアクセス可能です。

+0

それは働いた!お返事をありがとうございます!そんなばかげた間違い、私はそれを調べなかった。 – Duke

+0

歓迎します。将来の参考のために正解としてください。 –

0

あなたのリターンは、間違ったブロックである:

namespace BusinessLayer 
{ 
    public class StudentBusinessLayer 
    { 
     public List<Student> getStudents(string storedProcedure) 
     { 
      using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString)) 
      { 
       List<Student> students = new List<Student>(); 
       SqlCommand comm = new SqlCommand(storedProcedure, conn); 
       comm.CommandType = CommandType.StoredProcedure; 
       conn.Open(); 
       SqlDataReader rdr = comm.ExecuteReader(); 
       while (rdr.Read()) 
       { 
        Student s = new Student(); 
        s.id = Convert.ToInt32(rdr["id"]); 
        s.Name = rdr["Name"].ToString(); 
        s.TotalMarks = Convert.ToInt32(rdr["TotalMarks"]); 

        students.Add(s); 
       } 
      } 

      return students; 
     } 
    } 
} 
+0

ええ、私は他の試行錯誤の方法をしていたので、それらを入れてください。しかし、指摘してくれてありがとう! – Duke

+0

問題ありません。あなたのクラス「学生」が「公然」でないことについて他の人が正しいのですか?それは明らかに問題でもあります。 –

関連する問題