ASP更新ACCESS数据库修改资料

来源:百度知道 编辑:UC知道 时间:2024/06/18 14:39:16
<!--#include file="conn.asp"-->

<%
dim varusersex,varEmail,varqq,varnicheng,vargxqm
usersex=request.Form("usersex")
Email=request.Form("Email")
qq=request.Form("qq")
nicheng=request.form("nicheng")
gxqm=request.form("gxqm")
tou=request.form("tou")

dim rs,strspl
set rs=server.CreateObject("ADODB.Recordset")
strsql="update UserInfo set usersex='"& usersex &"'and Email='"& Email "'and QQ='"& QQ &"'and nicheng='"& nicheng &"'and gxqm='"& gxqm &"'and tou='"& tou &"'" & " where id=" & session("zl")
set rs=db.execute(strsql)
%>
<script language="javascript">
alert("资料修改成功!")
window.location.href='../index.asp';
</script>

直接换成下面这样试试:
strsql="update UserInfo set usersex='"& usersex &"',Email='"& Email & "',QQ='"& QQ &"',nicheng='"& nicheng &"',gxqm='"& gxqm &"',tou='"& tou &"' where id='"&session("zl")&"'

少了& ,而且要注意留空格。。。and 前面

strsql="update UserInfo set usersex='"& usersex &"' and Email='"& Email & "' and QQ='"& QQ &"' and nicheng='"& nicheng &"' and gxqm='"& gxqm &"' and tou='"& tou &"'" & " where id=" & session("zl")

程序写缺乏逻辑关系性,写的有点烦琐,我很不明白为什么要这么写:
strsql="..."
set rs=db.execute(strsql)
上边这两句完全可以一句的:db.execute("..")
而且最后也没有关闭数据库连接。

下边这个是我自己写的程序,自己看看吧:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
Action