ASP无法添加数据。(已解决)
自己太粗心了,P_D表内忘记设主键了。让大家见笑了。
哪位高人帮忙看看啊,怎么添加不进入数据呢?
我自己检查了半天,没看出问题所在。
下拉菜单那些数据显示都是正确的,就是添加不了数据,也没有见报错什么的。
先谢谢大家了!
<!--#include file="inc/conn.asp"-->
<%
If Request.Form("Submit") <> "" Then
Dim sql,Rs
sql = "select top 1 * from P_D"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open sql,conn,1,3
Rs.AddNew
Rs(1) = Request.Form("P_1")
Rs(2) = Request.Form("P_2")
Rs(3) = Request.Form("P_3")
Rs(4) = Request.Form("P_4")
Rs(5) = Request.Form("P_5")
Rs(6) = Request.Form("P_6")
Rs(7) = Request.Form("P_7")
Rs(8) = Request.Form("P_8")
Rs(9) = Request.Form("P_9")
Rs(10) = Request.Form("P_10")
Rs(11) = Request.Form("P_11")
Rs(12) = Request.Form("P_12")
Rs(13) = Request.Form("P_13")
Rs(14) = Request.Form("P_14")
Rs(15) = Request.Form("P_15")
Rs(16) = Request.Form("P_16")
Rs(17) = Request.Form("P_17")
Rs(18) = Request.Form("P_18")
Rs(19) = Request.Form("P_19")
Rs(20) = Request.Form("P_20")
Rs("P_NO") = Request.QueryString("id")
Rs.Update
Rs.Close
Set Rs = Nothing
response.write ("<script language=javascript> alert('添加成功!');history.go(-1);</script>")
response.end
End If
set rsd=server.CreateObject("adodb.recordset")
sql = "select * from P_A "
sql = sql & "where P_NO = " & Request.QueryString("id")
rsd.open sql,conn,1,1
dim rsp
set rsp = server.CreateObject("adodb.recordset")
sql="select * from P_i where P_NO = " & Request.QueryString("id")
rsp.open sql,conn,1,1
%>
<HTML>
<HEAD>
<TITLE>添加<%=rsp("P_Name")%></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312">
<LINK href="images/zh.css" type=text/css rel=stylesheet>
</HEAD>
<BODY LEFTMARGIN="0" TOPMARGIN="0">
<div id="formwrapper">
<h3>添加电脑配件</h3>
<FORM ACTION="P_add_i.asp" METHOD="post" NAME="P_add_i_Form" ID="P_add_i_Form">
<fieldset>
<legend>添加<%=rsp("P_Name")%></legend>
<%do while not rsd.eof%>
<div>
<label><%=rsd("P_Name")%></label>
<%if rsd("P_L")=1 then%>
<input type="text" name="P_<%=rsd("P_N")%>" id="P_<%=rsd("P_N")%>" size="18" maxlength="50">
<%else
dim rsb
set rsb = server.CreateObject("adodb.recordset")
sql="select * from P_C where P_B = " & rsd("P_B")
rsb.open sql,conn,1,1
%>
<select name="P_<%=rsd("P_N")%>" id="P_<%=rsd("P_N")%>">
<option>请选择</option>
<%do while not rsb.eof%>
<option value="<%=rsb("P_N")%>"><%=rsb("P_N")%></option>
<%
rsb.movenext
loop
%>
</select>
<%end if%>
</div>
<%
rsd.movenext
loop
%>
<div class="enter">
<INPUT TYPE="submit" NAME="Submit" class="buttom" VALUE="确认添加">
</div>
</fieldset>
</form>
</div>
</BODY>
</HTML>
[[it] 本帖最后由 letla 于 2008-9-17 17:07 编辑 [/it]]