asp无法写入数据了,总是提示资料库中已存在此资料'

来源:百度知道 编辑:UC知道 时间:2024/06/17 10:51:14
我是一个菜鸟,这是我第一个学习ASP制作的一个表单,代码是我自学或借鉴的,在我没加这段代码
if not rs.eof then
response.write"<script>alert('资料库中已存在此资料');history.go(-1)</script>"
else
前,可以写入数据库,就是无法判断资料库中有无相同数据(我主要是要求后两个即dh和qq字段不能完全相同)

-----------------------------------------------------------------

<%
set conn=server.createobject("adodb.connection")
connstr="Provider=Microsoft.jet.oledb.4.0;data source="&server.mappath("asp.mdb")
conn.open connstr
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>asp</title>
</head>

<body>
<%
set conn=server.createobject("adodb.connection")
conn.open "provider=microsoft.jet.oledb.4.0;data source="&server.mappath("asp.mdb")
yh=request.form("yh")
dh

如1楼,详细代码
strsql="select yh,dh,qq from sj"
改成
strsql="select yh,dh,qq from sj where dh='"+dh+"' and qq='"+qq+"'"

补充:
改成
strsql="select yh,dh,qq from sj where dh='"&dh&"' and qq='"&qq&"'"

在你判断是否已存在资料时,是不是应该加一个判断的条件啊
strsql="select yh,dh,qq from sj where 字段名=xxxx"