显然我遇到了语法错误,但我没有看到我的代码有任何问题!
if rs.EOF then
'User doesn't exist, create the record
query = currentDate&",'"
query = query + password & "','"
query = query + "user', '"
query = query + email & "', '"
query = query + fname & "', '"
query = query + sname & "'"
handle = add_to_database("users","jdate,password,perms,email,fname,sname",query)
response.write handle
else
response.write "Error: User already exists, please use a different email address"
end if
这是add_to_database函数
function add_to_database(where,column,values)
'Create query
sql = "INSERT INTO " & where & " (" & column & ") VALUES (" & values & ")"
on error resume next
'Add images to database
conn.Execute sql,recaffected
if err<>0 then
add_to_database = err.description &":"&sql&"<br />"
end if
'Destroy connection
sql = ""
end function
这是写入页面的错误
Syntax error in INSERT INTO statement.:INSERT INTO users (jdate,password,perms,email,fname,sname) VALUES (#2013/8/2#,'af453d19feb2520c8c0d30fb39ebd211','user', 'martynleeba@gmail.com', 'Martyn', 'Ball')
答案 0 :(得分:5)
users
表包含一个名为password
的字段。但是password
是reserved word,因此当它在查询中找到它时会混淆数据库引擎。如果可能,重命名该字段。如果你必须按原样保留名称,请将其括在方括号中,以表示数据库引擎它是一个对象名。
handle = add_to_database("users","jdate,[password],perms,email,fname,sname",query)