我有一个 asp.net MVC3 应用程序,试图将数据保存到 MS SQL 表(实体框架)。
这是表格:
public class CasesProgress
{
public virtual long ID { get; set; }
public virtual long Learner_ID { get; set; }
public virtual long Course_ID { get; set; }
public virtual long StudyCase_ID { get; set; }
public virtual long CaseList_ID { get; set; }
public virtual bool Viewed { get; set; }
}
这是我的控制器:
public ActionResult StoreProgress(long Learner_ID, long Course_ID, long StudyCase_ID, long CaseList_ID)
{
CasesProgress casesprogress = new CasesProgress();
casesprogress.Learner_ID = Learner_ID;
casesprogress.Course_ID = Course_ID;
casesprogress.StudyCase_ID = StudyCase_ID;
casesprogress.CaseList_ID = CaseList_ID;
casesprogress.Viewed = true;
db.CasesProgresses.AddObject(casesprogress);
db.SaveChanges();
return Json(new { success = true });
}
这是我的Javascript:
function StoreProgress1() {
$.ajax({
url: '/Home/StoreProgress',
type: 'POST',
data: {
LearnerID: "211",
Course_ID: "6",
StudyCase_ID: "19",
CaseList_ID: "2"
},
contentType: 'application/json; charset=utf-8',
success: function (data) {
alert(data.success);
},
error: function () {
alert("error");
}
});
}
我什至没有进入控制器中的断点就收到错误消息。任何想法,我都是新手。提前致谢。