Example #1
0
        public static int AddUser(string name, string username, string password, string type)
        {
            ConnectToDatabase c = new ConnectToDatabase();

            c.ConnectToDB();
            string query = "INSERT INTO users (Name,Username,Password,type) values ( '" + name + "' , '" + username + "' , '" + password + "', '" + type + "')";

            int result = c.UpdateQuery(query);

            c.CloseConnection();

            return(result);
        }
Example #2
0
        public static DataSet Authenticate(string userName, string password)
        {
            try
            {
                ConnectToDatabase c = new ConnectToDatabase();
                c.ConnectToDB();
                string query = "select * from Users where Username='******' AND Password='******' ";

                DataSet tempData = c.ExceuteQuerySet(query, "Users");
                c.CloseConnection();
                if (tempData.Tables[0].Rows.Count == 1) //Credentials matched with one record
                {
                    return(tempData);                   //return type of user
                }
                else
                {
                    return(null);
                }
            }
            catch
            {
                return(null);
            }
        }