我收到了这个错误:
异常详细信息:System.InvalidOperationException:2:字符串截断:max=0,len=1,value='3'。
从这组代码中:
var reqcategory=Request["category"];
foreach (var cat in reqcategory)
{
var sql5 = "SELECT Type.PreReq1, Type.PreReq2,
(CASE WHEN (Type.PreReq1 IS NOT NULL)
AND (PermitApp1.RPClass IS NULL)
AND (PermitApp1.RPCategory IS NULL)
THEN 1 ELSE 0 END) AS missing1,
(CASE WHEN (Type.PreReq2 IS NOT NULL)
AND (PermitApp2.RPClass IS NULL)
AND (PermitApp2.RPCategory IS NULL)
THEN 1 ELSE 0 END) AS missing2
FROM Type LEFT JOIN PermitApp AS PermitApp1
ON (Type.PreReq1=PermitApp1.RPClass)
OR (Type.PreReq1=PermitApp1.RPCategory)
AND ( PermitApp1.CDSID = @0 )
AND (PermitApp1.MDecision='1')
LEFT JOIN PermitApp AS PermitApp2
ON (Type.PreReq2=PermitApp2.RPClass)
OR (Type.PreReq2=PermitApp2.RPCategory)
AND ( PermitApp2.CDSID = @1 )
AND (PermitApp2.MDecision='1')
WHERE Type.PType = @2";
var result = db.QuerySingle(sql5, myCDSID, username, cat);
var miss1 = result.missing1;
var miss2 = result.missing2;
if(miss1 == '1' || miss2 == '1'){
ModelState.AddError("missing",
"You have not met the Pre-Requisites for "+ cat +" yet.");
} else if (miss1 == '0' && miss2 == '0'){
Session["license"] = Request["licence"];
Session["from"] = Request["from"];
Session["to"] = Request["to"];
Session["group"] = Request["group"];
Session["class1"] = Request["class1"];
Session["category1"] = Request["category1"];
Session["class"] = Request["class"];
Session["category"] = Request["category"];
Response.Redirect("~/Questionnaire");
}
}
突出显示的行是:
var result = db.QuerySingle(sql5, myCDSID, username, cat);
我不明白错误页面上提到的内容,也找不到与我的情况相同的人。谢谢