Subsonic 3, MySql, won't update record.

Posted by Warspawn on Stack Overflow See other posts from Stack Overflow or by Warspawn
Published on 2010-03-16T23:56:55Z Indexed on 2010/03/17 0:01 UTC
Read the original article Hit count: 676

Filed under:
|
|
|
|
[WebMethod]
    public string GetAuthToken(string username, string password)
    {
        var db = new LogicDB();
        //var results = from u in db.Users
        //              where u.Username == username && u.Password == password
        //              select u;

        User u = db.Select
            .From<User>()
            .Where(UsersTable.UsernameColumn).IsEqualTo(username)
            .And(UsersTable.PasswordColumn).IsEqualTo(password)
            .ExecuteSingle<User>();

        if (u == null)
        {
            return "{'success': false, 'reason': 'Invalid username and/or password.'}";
        }
        else
        {
            // really there should only be one match...
            Guid code = Guid.NewGuid();

            u.Securitycode = code.ToString();
            u.Securityexp = System.DateTime.Now.AddHours(24);

            //u.Save(db.Provider);

            return "{'id':'" + u.Id.ToString() + "', 'code':'" + code.ToString() + "', 'exp':'" + u.Securityexp.ToString() + "'}" + "\n\n<br/><br/>" + 
                u.GetDirtyColumns().ToArray().ToString();
        }
    }

When I run that, I keep getting:

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

This is when u.Save(db.Provider); is uncommented. And happens even with just u.Save(); or using the linq query above results instead.

© Stack Overflow or respective owner

Related posts about subsonic3

Related posts about mysql