日期:2014-05-18  浏览次数:20348 次

提示:语法错误 (操作符丢失) 在查询表达式 'FileStyle=审核order by FinanceID desc' 中。
public DataTable SelectStyleFinance(string FinanceStyle) 
  { 
  strOleDb = new StringBuilder(); 
  strOleDb.Append("select FinanceData as 收到日期,ArchivesNum as 归入案卷号,FileNum as 来文号,Department as 来文机关或部门,FileTitle as 拟办 FROM FINANCE"); 
  strOleDb.Append(" where FileStyle=" + FinanceStyle + ""); 
  strOleDb.Append("order by FinanceID desc"); 

  return DB.Fill(strOleDb.ToString()); 
  } 

提示:语法错误 (操作符丢失) 在查询表达式 'FileStyle=审核order by FinanceID desc' 中。 
什么错误 


------解决方案--------------------
'FileStyle=审核order by FinanceID desc'

前面就个空格
C# code
strOleDb.Append(" order by FinanceID desc ");

------解决方案--------------------
strOleDb.Append(" where FileStyle=" + FinanceStyle + ""); 
strOleDb.Append(" order by FinanceID desc");

少了空格
------解决方案--------------------
SQL code
'FileStyle='审核' order by FinanceID desc'

------解决方案--------------------
关注
------解决方案--------------------