我遇到了實體問題和保存問題我想更新記錄的值,因此我正在執行以下操作。用戶沒有物理輸入時引起問題的小數
我在其他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;
}
}
編輯1 唯一的例外是在這裏展示對不起,我不就沒怎麼包括圖像沒有鏈接當分數低於10時
可以請你展示異常,所以我們可以知道什麼是問題,拋出異常在哪裏? –
@TarekAboELkheir我已經在我的編輯中包含了一個屏幕截圖我只是想編輯一個現有的記錄,所以我不知道是什麼問題是非常誠實的 – rogue39nin