asp表单提交数据库显示一条记录的每个字段都为空值~怎么回事...有谁帮帮忙~急!
tijiao.htm:<formid="form1"name="form"method="post"action="action.asp"><tablewidth="92...
tijiao.htm:
<form id="form1" name="form" method="post" action="action.asp">
<table width="92%" height="160" border="1" align="center" cellpadding="0" cellspacing="0" bordercolordark="#FFFFFF" bordercolorlight="#666666">
<tr>
<td colspan="4"><div align="center">测试用的表单</div></td>
</tr>
<tr>
<td width="8%">姓名:</td>
<td width="39%"><input type="text" name="name" /></td>
<td width="9%">家庭住址:</td>
<td width="44%"><input type="text" name="address" /></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="text" name="sex" /></td>
<td>联系电话:</td>
<td><input type="text" name="tel" /></td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text" name="nianling" /></td>
<td>E-mail:</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>出生年月:</td>
<td><input type="text" name="both" /></td>
<td>特长:</td>
<td><input type="text" name="fev" /></td>
</tr>
<tr>
<td colspan="3"><input type="submit" name="Submit" value="提交" /></td>
<td><input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table>
</form>
action.asp:
<!--#include file="test.asp"-->
<%
dim rs,sql,rsRepeat
names=request.Form("name")
address=request.Form("address")
sex=request.Form("sex")
tel=request.Form("tel")
nianling=request.Form("nianling")
email=request.Form("email")
both=request.Form("both")
fev=request.Form("fev")
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from data "
rs.open sql,conn,1,3
rs.addnew
rs("name")=names
rs("address")=address
rs("sex")=StrReplace(sex)
rs("tel")=StrReplace(tel)
rs("nianling")=StrReplace(nianling)
rs("email")=StrReplace(email)
rs("both")=StrReplace(both)
rs("fev")=StrReplace(fev)
rs.update
rs.close
set rs=nothing
WriteMsg("·Submitted Success!,Come in<a href=main.asp><font color='red'>Home]</font></a>Back.")
%>
test.asp:
<%
Response.Buffer=True
On Error Resume Next
dbfolder="Data/"
dbname="tests.mdb"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(dbfolder&dbname)
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "<p style='font-size:9pt' align=center>数据库连接出错!</p>"
Response.Write "<p style='font-size:9pt' align=center>可能出错原因:数据库位置或名称不对、数据库损坏!</p>"
Response.End
End If%> 展开
<form id="form1" name="form" method="post" action="action.asp">
<table width="92%" height="160" border="1" align="center" cellpadding="0" cellspacing="0" bordercolordark="#FFFFFF" bordercolorlight="#666666">
<tr>
<td colspan="4"><div align="center">测试用的表单</div></td>
</tr>
<tr>
<td width="8%">姓名:</td>
<td width="39%"><input type="text" name="name" /></td>
<td width="9%">家庭住址:</td>
<td width="44%"><input type="text" name="address" /></td>
</tr>
<tr>
<td>性别:</td>
<td><input type="text" name="sex" /></td>
<td>联系电话:</td>
<td><input type="text" name="tel" /></td>
</tr>
<tr>
<td>年龄:</td>
<td><input type="text" name="nianling" /></td>
<td>E-mail:</td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>出生年月:</td>
<td><input type="text" name="both" /></td>
<td>特长:</td>
<td><input type="text" name="fev" /></td>
</tr>
<tr>
<td colspan="3"><input type="submit" name="Submit" value="提交" /></td>
<td><input type="reset" name="Submit2" value="重置" /></td>
</tr>
</table>
</form>
action.asp:
<!--#include file="test.asp"-->
<%
dim rs,sql,rsRepeat
names=request.Form("name")
address=request.Form("address")
sex=request.Form("sex")
tel=request.Form("tel")
nianling=request.Form("nianling")
email=request.Form("email")
both=request.Form("both")
fev=request.Form("fev")
set rs=Server.CreateObject("Adodb.Recordset")
sql="select * from data "
rs.open sql,conn,1,3
rs.addnew
rs("name")=names
rs("address")=address
rs("sex")=StrReplace(sex)
rs("tel")=StrReplace(tel)
rs("nianling")=StrReplace(nianling)
rs("email")=StrReplace(email)
rs("both")=StrReplace(both)
rs("fev")=StrReplace(fev)
rs.update
rs.close
set rs=nothing
WriteMsg("·Submitted Success!,Come in<a href=main.asp><font color='red'>Home]</font></a>Back.")
%>
test.asp:
<%
Response.Buffer=True
On Error Resume Next
dbfolder="Data/"
dbname="tests.mdb"
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(dbfolder&dbname)
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open connstr
If Err Then
err.Clear
Set Conn = Nothing
Response.Write "<p style='font-size:9pt' align=center>数据库连接出错!</p>"
Response.Write "<p style='font-size:9pt' align=center>可能出错原因:数据库位置或名称不对、数据库损坏!</p>"
Response.End
End If%> 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询