asp添加记录问题怎样解决

来源:百度知道 编辑:UC知道 时间:2024/05/24 02:20:36
程序是这样的:
<!--#include file="conn.asp"-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<%

username=request.Form("username")
password=request.Form("password")
city=request.Form("city")
age=request.Form("agel")
exec="insert into zhuche(username,password,city,age)values('"&username&"','"&password&"','"&city&"','"&age&"')"
conn.execute exec
conn.close
set conn=nothing
response.Redirect("default.asp")
%>
</body>
</html>
出现错误:
技术信息(用于支持人员)

错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] 操作必须使用一个可更新

检查下你的关键子,比如 username 加上 [] 一般可以解决的

如 insert into( [username] ,[系统关键字] ) 一般就不会出错了。

如果还是出错的话建议检查下字段类型。。

为什么不用
rs.addnew
rs("字段")=request.Form("username")
rs("字段")=request.Form("password")
rs("字段")=request.Form("city")
rs("字段")=request.Form("agel")
rs.update

同意楼上意见
改成这样的
<%

username=request.Form("username")
password=request.Form("password")
city=request.Form("city")
age=request.Form("agel")
rs.addnew
rs("username")=request.Form("username")
rs("password")=request.Form("password")
rs("city")=request.Form("city")
rs("age")=request.Form("age")
rs.update
conn.close
set conn=nothing
response.Redirect("default.asp")
%&