Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
namespace Auction
{
    class StatusUser
    {
        public enum UserStatus { user, administrator, unknown };
        public static UserStatus CheckUser(string uname, string password)
            {
            UserStatus result = UserStatus.unknown;
            SqlConnection conn = new SqlConnection(@"Data Source=ISAAC;Initial Catalog=licitatie;Integrated Security=True");
            SqlCommand cmd = new SqlCommand("select password,status from users where uname = Username", conn);
            SqlParameter p1 = new SqlParameter("username",uname);
            cmd.Parameters.Add(p1);
            SqlDataReader rdr;
            conn.Open();
            rdr = cmd.ExecuteReader();
            if (rdr.HasRows)
                {
                    rdr.Read();
                        if (rdr.GetString(0) == password)
                           result = (UserStatus)rdr.GetInt32(1);
                }
                    conn.Close();
               return result;
            }
    }


Error is:
UserStatus: member names cannot be the same as their enclosing type.

I changed Userstatus name but appears another errors...
Posted
Updated 27-Oct-14 4:01am
v2
Comments
KaushalJB 27-Oct-14 10:04am    
Which is the another error that comes?
isacgavrilas 27-Oct-14 10:06am    
if I change method name The type or namespace name 'UserStatuss' could not be found (are you missing a using directive or an assembly reference?)

Sergey Alexandrovich Kryukov 27-Oct-14 10:47am    
No, don't change type name. Change the names of the members of this type, and do it in all places.
Or change the type name, but everywhere.
—SA

If I import your code in it's entirety to one of my projects, and supply the missing "}" and the necessary using statement:
C#
using System.Data.SqlClient;
It compiles without error or warning on my system (VS 2010 Pro).

So the error has to be elsewhere.
First, try shutting down VS. Then reopen your solution, Clean it, and do a full rebuild. Does the problem persist?

Then look at your other files: Anything else that is called StatusUser?
Try changing the name of your class to XXStatusUser (and manually change teh references in that one file) Problem still there?
 
Share this answer
 
class StatusUser
{
public enum UserStatus { user, administrator, unknown };
public static UserStatus CheckUser(string uname, string password)
{
UserStatus result = UserStatus.unknown;
SqlConnection conn = new SqlConnection(@"Data Source=ISAAC;Initial Catalog=licitatie;Integrated Security=True");
SqlCommand cmd = new SqlCommand("select password,status from users where uname = Username", conn);
SqlParameter p1 = new SqlParameter("username",uname);
cmd.Parameters.Add(p1);
SqlDataReader rdr;
conn.Open();
rdr = cmd.ExecuteReader();
if (rdr.HasRows)
{
rdr.Read();
if (rdr.GetString(0) == password)
result = (UserStatus)rdr.GetInt32(1);
}
conn.Close();
return result;
}
}
i`ve make new calss with new name and solved this thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900