Syntax error (missing operator) in query expression
-
I have this problem with a SQL query that is executed through a c# program. it occurs in the following query: string strSql = "SELECT 2010Forms.Task_ID_PK, 2010Forms.isMainOutcome, 2010Forms.Outcome, "; strSql += " 2010Outcome.InProg, 2010Forms.OutcomeType, "; strSql += " 2010Outcome.TraineeStatus, 2010Outcome.ReviewerStatus "; strSql += " FROM 2010Outcome INNER JOIN 2010Forms ON "; strSql += " 2010Outcome.2010Outcome_ID_FK = 2010Forms.Task_ID_PK"; strSql += " where (2010Outcome.Review_ID_FK = '" + StringRevID "')"; strSql += " and (2010Outcome.Trainee_ID_FK = '" + StringTraineeID + "')"; strSql += " and (2010Forms.isFinal = 0)"; strSql += " order by 2010Forms.OutcomeOrder asc "; I cannot see any missing operators, but is anyone can assist me, I will be very greatful.
-
I have this problem with a SQL query that is executed through a c# program. it occurs in the following query: string strSql = "SELECT 2010Forms.Task_ID_PK, 2010Forms.isMainOutcome, 2010Forms.Outcome, "; strSql += " 2010Outcome.InProg, 2010Forms.OutcomeType, "; strSql += " 2010Outcome.TraineeStatus, 2010Outcome.ReviewerStatus "; strSql += " FROM 2010Outcome INNER JOIN 2010Forms ON "; strSql += " 2010Outcome.2010Outcome_ID_FK = 2010Forms.Task_ID_PK"; strSql += " where (2010Outcome.Review_ID_FK = '" + StringRevID "')"; strSql += " and (2010Outcome.Trainee_ID_FK = '" + StringTraineeID + "')"; strSql += " and (2010Forms.isFinal = 0)"; strSql += " order by 2010Forms.OutcomeOrder asc "; I cannot see any missing operators, but is anyone can assist me, I will be very greatful.
Two things: 1) Shouldn't you have a space between ".Outcome" and "Order"?
AlucardCode wrote:
strSql += " order by 2010Forms.OutcomeOrder asc ";
- You realy should use Parameters.AddWithValue rather than encoding IDs directly. Even if they are numeric it is good practice - avoid SQl injection problems!
All those who believe in psycho kinesis, raise my hand.
-
I have this problem with a SQL query that is executed through a c# program. it occurs in the following query: string strSql = "SELECT 2010Forms.Task_ID_PK, 2010Forms.isMainOutcome, 2010Forms.Outcome, "; strSql += " 2010Outcome.InProg, 2010Forms.OutcomeType, "; strSql += " 2010Outcome.TraineeStatus, 2010Outcome.ReviewerStatus "; strSql += " FROM 2010Outcome INNER JOIN 2010Forms ON "; strSql += " 2010Outcome.2010Outcome_ID_FK = 2010Forms.Task_ID_PK"; strSql += " where (2010Outcome.Review_ID_FK = '" + StringRevID "')"; strSql += " and (2010Outcome.Trainee_ID_FK = '" + StringTraineeID + "')"; strSql += " and (2010Forms.isFinal = 0)"; strSql += " order by 2010Forms.OutcomeOrder asc "; I cannot see any missing operators, but is anyone can assist me, I will be very greatful.
-
Cool Thanx, I will give it a try
-
I have this problem with a SQL query that is executed through a c# program. it occurs in the following query: string strSql = "SELECT 2010Forms.Task_ID_PK, 2010Forms.isMainOutcome, 2010Forms.Outcome, "; strSql += " 2010Outcome.InProg, 2010Forms.OutcomeType, "; strSql += " 2010Outcome.TraineeStatus, 2010Outcome.ReviewerStatus "; strSql += " FROM 2010Outcome INNER JOIN 2010Forms ON "; strSql += " 2010Outcome.2010Outcome_ID_FK = 2010Forms.Task_ID_PK"; strSql += " where (2010Outcome.Review_ID_FK = '" + StringRevID "')"; strSql += " and (2010Outcome.Trainee_ID_FK = '" + StringTraineeID + "')"; strSql += " and (2010Forms.isFinal = 0)"; strSql += " order by 2010Forms.OutcomeOrder asc "; I cannot see any missing operators, but is anyone can assist me, I will be very greatful.