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.
How should i declare a identifier?? anyway it is a string i think in the database it is nvarchar.
Yea i dont think that is going to work that way. Try this. For each is mean to loop through a collection, meaning you need to get the collection first then loop through it
var reqcategory=Request["category"];
foreach (var cat in reqctegory)
{
//the rest of your code here...
}
"He who would learn to fly one day must first learn to stand and walk and run and climb and dance; one cannot fly into flying."
Friedrich Nietzsche
Marked as answer by hubertjiang on Apr 23, 2012 06:09 PM
hubertjiang
0 Points
21 Posts
I have this error CS1001 (C#) But do not know how tosolve it.
Apr 23, 2012 05:31 PM|LINK
hi guys...i got this error:
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:
as highlighted by the compiler.
How should i declare a identifier?? anyway it is a string i think in the database it is nvarchar.
rickjames961
Participant
775 Points
174 Posts
Re: I have this error CS1001 (C#) But do not know how tosolve it.
Apr 23, 2012 05:49 PM|LINK
Yea i dont think that is going to work that way. Try this. For each is mean to loop through a collection, meaning you need to get the collection first then loop through it
var reqcategory=Request["category"]; foreach (var cat in reqctegory) { //the rest of your code here... }Friedrich Nietzsche
hubertjiang
0 Points
21 Posts
Re: I have this error CS1001 (C#) But do not know how tosolve it.
Apr 23, 2012 05:56 PM|LINK
alright that was fixed... but after that i got this funny error from this code:
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"); } }They say that CS1026: ) expected on
if(miss1 == 1 or miss2 == 1){Thanks
rrrsr7205
Participant
1304 Points
313 Posts
Re: I have this error CS1001 (C#) But do not know how tosolve it.
Apr 23, 2012 06:08 PM|LINK
"or" is not a valid operator in C#
use "!!"