i got this error:
Compiler Error Message: CS1001: Identifier expected
from this set of code:
var reqcategory="";
foreach(Request["category"] as 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, myCDSID, reqcategory);
var miss1 = result.missing1;
var miss2 = result.missing2;
}
The error happens to fall on this line:
foreach(Request["category"] as reqcategory)
as highlighted by the compiler.
Can anyone tell me what is my mistake?? And How should i declare a identifier??
Anyway what is an identifier? I cant seem to undertstand the explaination in http://msdn.microsoft.com/en-us/library/b839hwk4(VS.80).aspx
If its int i will use int.parse right but if it is string…how can i do so?
Thanks Thanks
BTW I am using webmatrix…
After i used JaredPar’s solution…the next error came…
CS1026: ) expected
in this part:
if (miss1 == '1' or miss2 == '1'){
ModelState.AddError("missing", "You have not met the Pre-Requisites for "+ cat +" yet.")
} else if (miss1 == '0' and 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");
}
on this line:
if (miss1 == '1' or miss2 == '1'){
Thanks…I don’t see why i need a ‘(‘ there…as i have closed all of it.
The problem is you have the structure of the
foreachloop backwards. In C# it’sidentifire in collection.Note that even this won’t be enough though as
Request[...]returnsobjectwhich isn’t a valid collection type in C#. You’ll need to specify the type of the underlying collection or usedynamic. The safest choice is a cast toIEnumerable