用asp向sql2000数据库中的表产品插入一条新纪录,输入一条,同一条数据总是插入两次。
<formmethod="post"action="add.asp"><table><tr><td>序号:</td><td><inputname="nubmer1"></...
<form method="post" action="add.asp">
<table>
<tr>
<td>序号:</td>
<td><input name="nubmer1"></td>
</tr><tr>
<td>ID:</td>
<td><input name="id1"></td>
</tr><tr>
<td>名字:</td>
<td><input name="name1"></td>
</tr><tr>
<td>属性:</td>
<td><input name="shuxing1"></td>
</tr><tr>
</table>
<br /><br />
<input type="submit" value="Add New">
<input type="reset" value="Cancel">
</form>
<body>
<%
number1=request("number1")
id1=request("id1")
name1=request("name1")
shuxing1=request("shuxing1")
sql="INSERT INTO chanpin (number,id,name,shuxing) VALUES ('"&number1&"','"&id1&"','"&name1&"','"&shuxing1&"')"
conn.execute sql
on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>
</body> 展开
<table>
<tr>
<td>序号:</td>
<td><input name="nubmer1"></td>
</tr><tr>
<td>ID:</td>
<td><input name="id1"></td>
</tr><tr>
<td>名字:</td>
<td><input name="name1"></td>
</tr><tr>
<td>属性:</td>
<td><input name="shuxing1"></td>
</tr><tr>
</table>
<br /><br />
<input type="submit" value="Add New">
<input type="reset" value="Cancel">
</form>
<body>
<%
number1=request("number1")
id1=request("id1")
name1=request("name1")
shuxing1=request("shuxing1")
sql="INSERT INTO chanpin (number,id,name,shuxing) VALUES ('"&number1&"','"&id1&"','"&name1&"','"&shuxing1&"')"
conn.execute sql
on error resume next
conn.Execute sql,recaffected
if err<>0 then
Response.Write("No update permissions!")
else
Response.Write("<h3>" & recaffected & " record added</h3>")
end if
conn.close
%>
</body> 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询