2016-08-20 5 views
0

エンティティに問題があり、保存しています。次のようにレコードの値を更新したいと思います。ユーザーが物理的に入力していないときに小数点が発生する

私は他のoensで次のものを使用しますが、キーがすでに存在するというレコードを保存する何らかの理由でここでは機能しません。ここで

_dal.portalEntities.Entry(_custInfo).State = System.Data.Entity.EntityState.Modified; 
_dal.portalEntities.SaveChanges(); 
_dal.portalEntities.Entry(_custInfo).Reload(); 

は私のメインルーチン

tblPortalUser _users; 
_users = _dal.GetUserRecordByEmail(_myuser.EmailAddress.ToLower()); 
//password is the same warn the user as current 
if (PasswordHash.ValidatePassword(password.Text, _users.password) == true) 
{  
    lblerror.Text = "Password choose a password you have not used before"; 
    }else 
lblerror.Text = "Current Password is invalid."; 
      // if password is the same as the confirm password then proceed if not warn the user 
if (password.Text == confirmpass.Text) 
{ 
    _users.password = PasswordHash.HashPassword(password.Text); 
    _dal.portalEntities.SaveChanges(); 
//lets send out the verification codes for the email and sms 
    _notifications.sendNotification(new Guid(portalbl.BLConstants.resetPasswordEmail), _custInfo.firstName + " " + _custInfo.lastName, "", _custInfo.email.ToLower(), "", "", portalbl.BLConstants.portalNotifications.Email, ""); 
Response.Redirect(@"~\myaccount\logout.aspx", false); 
} 

GetUserRecordByEmailある

public tblPortalUser GetUserRecordByEmail(string Email) 
    { 
     try 
     { 
      tblPortalUser _user; 

      _user = (from _users in _dal.portalEntities.tblPortalUsers 
        where _users.EmailAddress.ToLower() == Email 
        select _users).FirstOrDefault(); 


      return _user; 
     } 
     catch (Exception ex) 

     { 
      string inner = string.Empty; 
      if (ex.InnerException != null) 
      { 
       inner = ex.InnerException.ToString(); 
      } 
      return null; 
     } 
    } 

編集例外iはリンクせずに画像を含める方法はありませんありません申し訳ありません、ここで示している1 スコアが10歳未満の場合

https://snag.gy/QMSzaE.jpg

+0

あなたが示してくださいすることができます私たちは何が問題なのかを知ることができ、例外はどこにスローされましたか? –

+0

@TarekAboELkheir編集画面にスクリーンショットを追加しました。既存のレコードを編集しようとしていますので、問題は正直ではありません。 – rogue39nin

答えて

0

スクリーンショットからは、例外がクリアされて、ユーザーを外し、再度接続し、そしてそれは、この記事へ

を見ていきます最初の必要があります。Attaching and Detaching Objects

+0

@Tarerkはこの例をお試しください。 – rogue39nin

+0

@Tarerik canあなただけの例ではなく、リンクを表示してください – rogue39nin