Пример #1
0
        public string Login()
        {
            SqlConnection con = new SqlConnection("Data Source=KUTTYCHATTAN-PC;Integrated Security=True");
            string str;
            con.Open();
            str = "select * from  Userlogin";
            SqlCommand cmd = con.CreateCommand();
          //  cmd.Dispose();
            //con.Close();
            SqlDataReader rdr=cmd.ExecuteReader();
            Logginuser logg =new Logginuser();
            while(rdr.Read())
            {
                if(((logg.LoginID.Equals(rdr["LoginID"].ToString()))&&(((logg.Password.Equals(rdr["Password"].ToString())))
                {     
                    logg.LoginID=rdr["LoginID"].ToString();
                    logg.Password=rdr["Password"].ToString();

                }
            }


           
        
        }  
Пример #2
0
        public string Login(string X_uname, string X_passwd)
        {
            SqlConnection con = new SqlConnection("Data Source=KUTTYCHATTAN-PC\\SQLEXPRESS;Initial Catalog=facebooklogin;Integrated Security=True");

            con.Open();
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandText = "select * from Userlogin";
            //  cmd.Dispose();
            //con.Close();
            SqlDataReader rdr  = cmd.ExecuteReader();
            Logginuser    logg = new Logginuser();

            logg.Username = X_uname;
            logg.Password = X_passwd;
            while (rdr.Read())
            {
                if ((logg.Username.Equals(rdr["username"].ToString())) && (logg.Password.Equals(rdr["Password"].ToString())))
                {
                    logg.Firstname  = rdr["Firstname"].ToString();
                    logg.Lastname   = rdr["Lastname"].ToString();
                    logg.Username   = rdr["Username"].ToString();
                    logg.LoginID    = Convert.ToInt32(rdr["LogginId"].ToString());
                    logg.X_LoginID  = logg.LoginID.ToString();
                    logg.Profilepic = rdr["Profilepic"].ToString();
                    string str = "LoginId:" + logg.LoginID + "Firstname:" + logg.Firstname + "Lastname:" + logg.Lastname + "Profilpic:" + logg.Profilepic + "Responsecode;200 Message;success";
                    return(str);
                }
                else if ((logg.Username.Equals(rdr["username"].ToString())) && (!(logg.Password.Equals(rdr["password"].ToString()))))
                {
                    logg.Firstname  = rdr["Firstname"].ToString();
                    logg.Lastname   = rdr["Lastname"].ToString();
                    logg.Username   = rdr["Username"].ToString();
                    logg.LoginID    = Convert.ToInt32(rdr["LogginId"].ToString());
                    logg.X_LoginID  = logg.LoginID.ToString();
                    logg.Profilepic = rdr["Profilepic"].ToString();
                    string str = "Responsecode;404 Message;Password incorrect";
                    return(str);
                }
                else if (!(logg.Username.Equals(rdr["Username"].ToString())) && (!(logg.Password.Equals(rdr["Password"].ToString()))))
                {
                    logg.Firstname  = rdr["Firstname"].ToString();
                    logg.Lastname   = rdr["Lastname"].ToString();
                    logg.Username   = rdr["Username"].ToString();
                    logg.LoginID    = Convert.ToInt32(rdr["LogginId"].ToString());
                    logg.X_LoginID  = logg.LoginID.ToString();
                    logg.Profilepic = rdr["Profilepic"].ToString();
                    string str = "Username:"******"Responsecode;500 Message;Email id doesnot exist";
                    return(str);
                }
            }
            return(null);
        }