Click here to Skip to main content
15,905,614 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two tables in the database:

SQL
Login (LID,UName,UPasword,UserType_ID)

UserType(UserType_ID,UserType)


I need to validate username and usertype and create a session variable for UserName(UName).

Below is the code which I try but it shows me error
Error   58  The type or namespace name 'UserInformation' could not be found (are you missing a using directive or an assembly reference?)   

CODE

C#
public string LogOn(UserInformation objLogOnUserInformation)
{
   // ConnectionManager conCm = new ConnectionManager();
   try
   {
      MySqlConnection con = conn.Open();
      MySqlCommand cmd, cmdOne;
      MySqlDataReader dr;
      // SqlDataReader dr;
      string _str = "U";
      cmd = new MySqlCommand("select LID  from Credentials", con);
      dr = cmd.ExecuteReader();

      while (dr.Read())
      {
         //checking user name is present in database
         if (dr.GetValue(0).ToString() == objLogOnUserInformation.UserId)
         {
            dr.Close();
            //retriving Password for the existing user
            cmd = new MySqlCommand("select Pasword  from login where LID='" + objLogOnUserInformation.UserId + "'", con);
            dr = cmd.ExecuteReader();

            while (dr.Read())
            {
               //checking the password is matching with the database
               if (dr.GetValue(0).ToString() == objLogOnUserInformation.Password)
               {
                  dr.Close();
                  cmd = new MySqlCommand("select UserType_ID  from login where LID='" + objLogOnUserInformation.UserId + "'", con);
                  dr = cmd.ExecuteReader();

                  while (dr.Read())
                  {
                     //checking user type 
                     if (dr.GetValue(0).ToString() == _str)
                     {
                        dr.Close();
                        cmdOne = new MySqlCommand("select UName from login where LID='" + objLogOnUserInformation.UserId + "'", con);
                        dr = cmdOne.ExecuteReader();
                        dr.Read();
                        objLogOnUserInformation.SessionUserName = dr.GetValue(0).ToString();
                        dr.Close();
                        //if usertype is customer, U is returned
                        Response.Redirect("gallery.aspx");
                     }
                     else
                     {
                        dr.Close();
                        cmdOne = new MySqlCommand("select UName from login where LID='" + objLogOnUserInformation.UserId + "'", con);
                        dr = cmdOne.ExecuteReader();
                        dr.Read();
                        objLogOnUserInformation.SessionUserName = dr.GetValue(0).ToString();
                        dr.Close();
                        //If usertype is Admin, A is returned
                        Response.Redirect("Reports.aspx");
                     }
                  }
               }
               else
               {
                  return " Either User Name or Password is not Valid";
               }
            }
         }
      }
   }
   catch
   {
   }
}


any help?
Posted
Updated 1-Oct-14 1:14am
v2
Comments
Kornfeld Eliyahu Peter 30-Sep-14 5:50am    
You use UserInformation as a type (class) name, but it's not clear from your code what is it? It's not a .NET class as much as I know, so it's probably one of your own creature...You may miss a reference to the project in which you defined the type...

1 solution

UserInformation is a class correct?. If so you need to do the following

1) Add an assembly reference if its in a different assembly
2) Add a namespacew for the same

If you have not created UserInformation you can create UserInformation class with required properties.
 
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