Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Syntax error (missing operator) in query expression

Syntax error (missing operator) in query expression

Scheduled Pinned Locked Moved C#
databasehelpcsharp
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AlucardCode
    wrote on last edited by
    #1

    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.

    OriginalGriffO G L 3 Replies Last reply
    0
    • A AlucardCode

      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.

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Two things: 1) Shouldn't you have a space between ".Outcome" and "Order"?

      AlucardCode wrote:

      strSql += " order by 2010Forms.OutcomeOrder asc ";

      1. 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 no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      1 Reply Last reply
      0
      • A AlucardCode

        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.

        G Offline
        G Offline
        Ghydo
        wrote on last edited by
        #3

        Maybe using table names starting with a number can be a problem: identifiers starting with a number has a special meaning in SQL server (documentation here[^]). Try enclosing the identifiers inside square brakets (eg [2010Outcome].InProg). I'm not sure this is your problem through. :confused:

        A 1 Reply Last reply
        0
        • G Ghydo

          Maybe using table names starting with a number can be a problem: identifiers starting with a number has a special meaning in SQL server (documentation here[^]). Try enclosing the identifiers inside square brakets (eg [2010Outcome].InProg). I'm not sure this is your problem through. :confused:

          A Offline
          A Offline
          AlucardCode
          wrote on last edited by
          #4

          Cool Thanx, I will give it a try

          1 Reply Last reply
          0
          • A AlucardCode

            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.

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            missing plus sign strSql += " where (2010Outcome.Review_ID_FK = '" + StringRevID "')"; strSql += " where (2010Outcome.Review_ID_FK = '" + StringRevID :) + "')";

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups