UPDATE语法错误。 [英] UPDATE Syntax error.

查看:78
本文介绍了UPDATE语法错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





每次运行下面的代码我都会在UPDATE语句中出现语法错误,但我看不出原因 - 有人可以帮忙吗? br $> b $ b

Hi,

Everytime I run the code below I get a syntax error with the UPDATE statement, but I can't see why - can anyone help?

Dim cmd As New OleDbCommand
            cmd.Parameters.Clear()

            strSQL = "UPDATE tbl_users SET password = @newpassword WHERE ID = @userid"

            cmd.Parameters.AddWithValue("@newpassword", hashed_password)
            cmd.Parameters.AddWithValue("@userid", frm_UAC_userid)
            cmd.CommandText = strSQL
            cmd.Connection = objconn
            cmd.ExecuteNonQuery()

推荐答案

更改哟你的sql as

change your sql as
UPDATE tbl_users SET [password] = @newpassword WHERE [ID] = @userid



当你将它们用作列名或表名时需要用[]包围的保留字


reserved words need to surround with [] when you use them as column names or table names


可以你发布了完整的错误。



使用try catch
Could you post the complete error.

Use try catch


谢谢。我不应该在深夜编写代码,因为我似乎错过了基础知识
Thank-you. I shouldn't write code late at night as I seem to miss the basics


这篇关于UPDATE语法错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆