-4
나는 거기에 있더라도 'GetUser'라는 메서드가 없다는 오류가 있습니다. 오류 메시지 : "System.Security.Principal.IPrincipal '않습니다 '인 getUser'없이 확장 방법에 대한 정의를 포함하지 '인 getUser'유형 'System.Security.Principal.IPrincipal'의 첫 번째 인수를 받아들이는 것은내 코드가 Visual Studio에서 작동하지 않는다
이 사용자 클래스 내 코드 "볼 수 있습니다
public static List<User> GetUser()
{
SqlConnection conn = null;
List<User> result = new List<User>();
try
{
conn = new SqlConnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["2ndEardbConnectionString"].ConnectionString;
conn.Open();
SqlCommand comm = new SqlCommand();
comm.Connection = conn;
comm.CommandText = "select * from User";
SqlDataReader dr = comm.ExecuteReader();
while (dr.Read())
{
User u = new User();
u.Name = (string)dr["Name"];
u.UserName = (string)dr["UserName"];
u.Password = (string)dr["Password"];
u.DOB = (DateTime)dr["DOB"];
u.Gender = (string)dr["Gender"];
u.Email = (string)dr["Email"];
u.ContactNumber = (int)dr["ContactNumber"];
u.ProfilePic = (byte)dr["ProfilePic"];
u.Image = (byte)dr["Image"];
result.Add(u);
}
dr.Close();
}
catch (SqlException e)
{
throw e;
}
finally
{
conn.Close();
}
return result;
}
형태로, 이것은 내가 넣은 코드입니다.
protected void Button1_Click(object sender, EventArgs e)
{
List<User> results = User.GetUser();
foreach (User u in results)
{
if (TextBox8.Text.ToString() == u.UserName.ToString())
{
Label13.Visible = true;
break;
}
else
{
Label12.Visible = true;
}
}
}
그러나 User.GetUser()에서 오류가 발생합니다.
메서드가 없다는 것을 나타냅니다.
어떻게 당신이 getUser 메소드를 호출하지 않는
어디서 사용자 등급을 지정 했습니까? using 지시문이 누락 되었습니까? – Thousand
'GetUser' 함수가 올바르게 보입니다. 'User' 클래스에 실제로 있습니까? 컴파일러가 동의하지 않는 것 같습니다. 'User' 클래스의 코드를 게시 할 수 있습니까? – Mizipzor
이 질문의 제목을 변경하십시오. –