简体   繁体   English

SQL Server错误“ 80040e14”,语法错误在“ ORDER”附近

[英]SQL Server error '80040e14' with syntax error nearby “ORDER”

I have been getting the SQL Server error '80040e14' saying Incorrect syntax near the keyword 'ORDER'. 我一直在收到SQL Server错误“ 80040e14”,在关键字“ ORDER”附近说语法不正确。 However, the line it is pointing is the next line to the line where there is the word "ORDER" Can someone point out the syntax mistake I did in the following sql code? 但是,它所指向的行是单词“ ORDER”所在行的下一行。有人可以指出我在以下sql代码中遇到的语法错误吗? ASP is the language I have been using for this project. ASP是我在该项目中一直使用的语言。

SQL = " SELECT TS.ID, types"&_
      " FROM tblTickets TS"&_
      " WHERE TS.ID = "& Request("ticketid") &" ORDER BY dateof DESC"

SET RSticket = objConn.Execute(SQL) SET RSticket = objConn.Execute(SQL)

So,it points error in the last line whereas "ORDER" is in different line. 因此,它在最后一行中指出错误,而“ ORDER”在另一行中。

If Request("ticketid") returns a string value then you need to add single quotes around it: 如果Request(“ ticketid”)返回一个字符串值,则需要在其周围添加单引号:

SQL = " SELECT TS.ID, types"&_
      " FROM tblTickets TS"&_
      " WHERE TS.ID = '"& Request("ticketid") &"' ORDER BY dateof DESC"

the ORDER BY will fail, because dateof isnt a selected field ORDER BY将失败,因为dateof不是所选字段

try " WHERE TS.ID = "& Replace(Request("ticketid"),"'","''") &" ORDER BY 1 DESC" 尝试" WHERE TS.ID = "& Replace(Request("ticketid"),"'","''") &" ORDER BY 1 DESC"

谢谢大家,我只是缺少&Request(“ ticketid”)的单引号引起来。现在它可以正常工作了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SQL Server错误'80040e14'列名不明确 - SQL Server error '80040e14' Ambiguous column name 具有多个Insert语句的SQL Compact错误80040E14 - SQL Compact Error 80040E14 with multiple Insert statement SQL Server的Microsoft OLE DB提供程序错误'80040e14'无效的列名。 SQL查询 - Microsoft OLE DB Provider for SQL Server error '80040e14' Invalid column name . SQL query 尝试从 SQL Server 检索数据时出现 VBA ADODB 错误 (80040e14) - VBA ADODB error (80040e14) when trying to retrieve data from SQL Server 经典ASP Microsoft SQL Server本机客户端11.0错误'80040e14'用户登录失败,但不是我指定的用户登录 - Classic ASP Microsoft SQL Server Native Client 11.0 error '80040e14' Login failed for user, but not the one I specified 运行时错误“-2147217900 (80040e14)”:“1”附近的语法不正确 - Run-time error' -2147217900 (80040e14)': Incorrect syntax near '1' 如何解决此ASP错误“ 80040e14”? - How can I solve this ASP error '80040e14'? 错误:Ms 访问 VBA 代码中的 2147217900(80040e14) - error: 2147217900(80040e14) in Ms access VBA code ODB错误80040e14 ASP CLASSIC - ODB ERROR 80040e14 ASP CLASSIC 迁移问题:ASP经典应用程序中的错误“ 80040e14”从Windows Server 2003 / SQL Server 2000迁移到Windows Server 2008 R2 / SQL Server 2012 - Migration Issue: error '80040e14' in ASP classic application from Windows server 2003/SQL Server 2000 to Windows Server 2008 R2/SQL Server 2012
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM