繁体   English   中英

Vb6缺少运算符

[英]Vb6 Missing Operator

在我的学校项目上工作时,尽管我将其余代码运行正常,但在将ORDER BY方面添加到我的sql时却遇到了此丢失的运算符错误。

Set rs_fav = db_kwickfix.OpenRecordset("
    SELECT Recipe.Rec_Name 
    FROM Recipe,Favourites 
    WHERE (Recipe.RecipeID = Favourites.RecipeID) 
        AND (Favourites.UserID = " & frm_login.user_id & ") 
    ORDER BY Recipe.Rec_Name DESCENDING
    ")

尝试使用DESC而不是DESCENDING ,请检查ORDER BY子句(Transact-SQL)

ORDER BY order_by_expression
[COLLATE collat​​ion_name]
[ASC | ]
[,... n]
[<offset_fetch>]

从而:

Set rs_fav = db_kwickfix.OpenRecordset("
    SELECT Recipe.Rec_Name 
    FROM Recipe,Favourites 
    WHERE (Recipe.RecipeID = Favourites.RecipeID) 
        AND (Favourites.UserID = " & frm_login.user_id & ") 
    ORDER BY Recipe.Rec_Name DESC
    ")

您是否考虑过使用显式JOIN?

Set rs_fav = db_kwickfix.OpenRecordset("
        SELECT Recipe.Rec_Name 
        FROM Recipe
        JOIN Favourites
        ON Recipe.RecipeID = Favourites.RecipeID
        AND Favourites.UserID = " & frm_login.user_id & " 
        ORDER BY Recipe.Rec_Name DESC
    ")

另外,我强烈建议您研究参数化查询,以便您开始养成使用它们的习惯。 在此处了解更多信息。

暂无
暂无

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM