Monday, 15 February 2010

mysql - Trying to update table in asp.net -



mysql - Trying to update table in asp.net -

saving alter temp variable successful when debugging can see values changing, when seek save changes database, required field not beingness changed.

i trying alter value of field 'being investigated' 'closed'

nemesysentities db2 = new nemesysentities(); study report = db2.reports.find(investigation.report_id); report_status rep = db2.report_status.find(3); report.report_status = rep; report.report_status.description = "closed"; report.report_status.id = 3; db2.entry(report).state= entitystate.modified; db2.savechanges();

the table stores reports called reports, , investigation.report_id represents id of study beingness investigated. hence passing study id value, table should find study in reports table , alter value of action status closed, below line of code, (the id of action "closed" in database 3)

report_status rep = db2.report_status.find(3);

however required changes in database not beingness stored. ideas??

this model of report

namespace webapplication2.models { using system; using system.collections.generic; using system.componentmodel; using system.componentmodel.dataannotations; using system.data.entity; using system.data.entity.validation; using system.diagnostics; using system.web; public partial class study { public report() { this.investigations = new hashset<investigation>(); httpcookie _userid = system.web.httpcontext.current.request.cookies["user"]; string userid=""; nemesysentities db = new nemesysentities(); if(_userid!=null) { this.user_id = convert.toint32(_userid["id"]); user temp=db.users.find(user_id); this.email = temp.email; this.phone = temp.phone; temp.confirmpassword = temp.password; int = temp.points; i++; temp.points = i; db.entry(temp).state = entitystate.modified; seek { db.savechanges(); } grab (dbentityvalidationexception dbex) { foreach (var validationerrors in dbex.entityvalidationerrors) { foreach (var validationerror in validationerrors.validationerrors) { trace.traceinformation("property: {0} error: {1}", validationerror.propertyname, validationerror.errormessage); } } } } else { this.user_id = 13; } this.status_id = 1; } public int id { get; set; } [display(name = "date of near miss")] public system.datetime date { get; set; } [display(name = "location")] public string location { get; set; } [displayname("type")] public int type_id { get; set; } [display(name = "description")] public string description { get; set; } public int status_id { get; set; } public int user_id { get; set; } [display(name = "email address")] public string email { get; set; } [display(name = "phone number")] public string phone { get; set; } public int votes { get; set; } public virtual icollection<investigation> investigations { get; set; } public virtual report_status report_status { get; set; } public virtual report_type report_type { get; set; } public virtual user user { get; set; } } }

this model of investigator. can see in 1 of setters using same method attempting utilize alter status of report.

namespace webapplication2.models { using system; using system.collections.generic; using system.componentmodel.dataannotations; using system.data.entity; using system.data.entity.validation; using system.diagnostics; using system.web; public partial class investigation { public investigation() { httpcookie _userid = system.web.httpcontext.current.request.cookies["user"]; if (_userid != null) { this.investigator_id = convert.toint32(_userid["id"]); //5 primary key of "being investigated" in type of action this.action_id = 5; this.cause = ""; this.date_of_action = new datetime(2012, 1, 3); } } public int id { get; set; } [display (name="formal description")] public string formal_description { get; set; } [display(name = "cause of hazard")] public string cause { get; set; } [display(name = "action take")] public int action_id { get; set; } [display(name = "date of action")] public system.datetime date_of_action { get; set; } public int investigator_id { get; set; } int _report_id; [display(name = "report id:")] public int report_id { { homecoming _report_id; } set { _report_id = value; nemesysentities db = new nemesysentities(); study report = db.reports.find(this.report_id); //2 primary key of "being investigated" in study status report_status rep = db.report_status.find(2); report.report_status = rep; db.entry(report).state = entitystate.modified; seek { db.savechanges(); } grab (dbentityvalidationexception dbex) { foreach (var validationerrors in dbex.entityvalidationerrors) { foreach (var validationerror in validationerrors.validationerrors) { trace.traceinformation("property: {0} error: {1}", validationerror.propertyname, validationerror.errormessage); } } } } } public virtual investigation_action investigation_action { get; set; } public virtual study report { get; set; } public virtual user user { get; set; } }

}

mysql asp.net asp.net-mvc asp.net-mvc-5

No comments:

Post a Comment