DW与ACCESS数据连接不成功,当提交表单,数据添加不到数据库的表中

2025-03-28 21:44:23
推荐回答(1个)
回答1:

分析:
你的connregist.asp文件中的数据库连接代码是正确的。
你的regist1.asp文件中,
userpssword userpassword 的写法不统一,少了一个“a”
你原先的 regist1.asp 页面中没有加判断,所以你执行此文件时,会插入一个空记录,
在获取页面,可以加一个判断,如果直接浏览获取页面将转到表单页面,
在表单页面,只有填写了信息,才能提交到获取页面。

数据库:
数据库名:db1.mdb
数据库表名:regist1
字段:
ID 自动编号
regname 文本
regpassword 文本
regxb 文本
regch 文本

一、表单页面:reg_form.asp


会员注册信息


用户名:


密码:


性别:

保密


个人爱好:




二、获取代码页面:regist1.asp

<%
dim username,userpssword,userxb,userch
submit=Request.Form("submit")
username=Request.Form("username")
userpassword=Request.Form("userpassword")
userxb=Request.Form("userxb")
userch=Request.Form("userch")
if submit<>"确定注册" then
response.Write("")
response.End()
end if
if username="" and userpassword="" and userxb="" and userch="" then
response.Write("")
else
sql="insert into regist1(regname,regpassword,regxb,regch)values('"+username+"','"+userpassword+"','"+userxb+"','"+userch+"')"
' Response.Write(sql)
' Response.End()
conn.execute(sql)
conn.close()
response.Write("")
end if
%>