苏州二手房链家:asp FROM 子句语法错误。

来源:百度文库 编辑:中科新闻网 时间:2024/04/28 08:21:23
set conn=server.createobject("adodb.connection") '创建数据库连接
set rs=server.createobject("adodb.recordset") '创建记录集
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("data/mydd.mdb") '指定连接路径
conn.open connstr
strsql="select * from user where username='" & username & "' and userpassword='" & stroldpassword & "'"
strchangesql="update user set userpassword='" & strnewpassword & "' where username='" & username & "' and userpassword='" & stroldpassword & "'"
set rs=conn.execute(strsql)
%>

strchangesql="update user set userpassword='" & strnewpassword & "' where username='" & username & "' and userpassword='" & stroldpassword & "'"

需要修改的字段userpassword,同时又是查询的条件--这种写法很不明智!

你的user表的主关键字段(字段值不可重复)是什么?
如果是username的话,则where子句后的:
and userpassword='" & stroldpassword & "'"
这一段可去掉。

如果主关键字段是其它的,如:UserId,则SQL语句可写成:
strchangesql="update user set userpassword='" & strnewpassword & "' where userid='" & userid & "'"