Posted on: 1/15/2014 4:34:44 PM | Views : 564

Hi all,
  Whenever there is single quote character in Operator name in the databasethen getting this error
Incorrect syntax near 'BENCO'. Unclosed quotation mark after the character string ' GROUP BY  OperatorID,Operator,District ORDER BY TotalSpend DESC '.
so how to write this sql statement which will not give this type of error.
  "SELECT " + strR + ",OperatorID,Operator, Count(DISTINCT WellId) AS WellCount,"                     + " SUM(TotalValue) AS TotalSpend FROM tbl_view_WellProductLines2"                     + " WHERE " + strColumnName1 + " IN(" + strId + ") AND "           ...

Go to the complete details ...