日期:2014-05-16  浏览次数:20912 次

asp保存出现空白,求大神帮忙检查一下
本帖最后由 u011120650 于 2014-04-29 15:43:59 编辑
本人想做一个二级省市联动,保存的的时候,保存页面显示空白,写入数据库失败

省份数据库zdjg 结构 dm(序号)  mc(名称)
市数据库zdcity  结构dm(序号)【数据库自增长】 mc【市】id【省份的序号】
前台代码
<form name='formEdit' action='city_save.asp' target="sub"  METHOD='POST'>
<tr class=InputFrameLine> 
<td class="InputLabelCell" align="right" width="40"> 省份</td>
<td class="InputLabelCell"  width="150">
            <select name="cboJG" id="cboJG"  style="width:100%">
<%rsZD.Open "Select * from zdJG",conn
do while not rsZD.EOF
%>
<option value="<%=rsZD("DM")%>"><%=rsZD("MC")%></option>
<%
rsZD.MoveNext
loop
rsZD.Close%>
</select>
</td></tr>
<tr class=InputFrameLine> 
<td class="InputLabelCell" align="right" width="40"> 城市</td>
<td class="InputLabelCell"  width="150">
<input type="text" name="txtNR" id="txtNR"  class="input" style="width:100%">
</td>
</tr>                

<tr class='InputFrameButtonLine'>
<td align="center" colspan="2">
<input type='button' class='button' value='保存' onclick='javascript:doSave()' >
<input type='reset' class='button' value='放弃'  id='reset' name='reset'>
<input type='button' class='button' value='返回' onClick="vbscript:location.href='zdgl.asp?ZDBM=ZDCITY&type=rs'" >
</td>
</tr>

</form>

保存代码
<%@ Language=VBScript %>
<!-- #include file="..\share\connectdb.asp" -->
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<%
cboJG= request("cboJG") 
city = request("txtNR")
Set rs1=Server.CreateObject("ADODB.Recordset")
sqltable = "select dm from zdjg where mc='"&cboJG&"'"
rs1.open sqltable,conn,1,1
if not rs1.eof then
id = rs1("dm")
end if
rs1.Close()

on error resume next
'打开表连接
Set rs=Server.CreateObject("ADODB.Recordset")

'增加记录
sqltable="select * from zdcity"
rs.open sqltable,conn,3,3

rs.AddNew 
rs("mc")= city
rs("id")= id
rs.Update 
%>
<script language=javascript>
alert("保存成功!");
parent.location.href='zdgl.asp?ZDBM=ZDCITY&type=rs'
</script>
<%
rs.Close()
set rs = nothing
conn.close
set conn = nothing
%>
</BODY>
</HTML>

------解决方案--------------------
cboJG= request("cboJG") 
city = request("txtNR")
response.write cboJG
response.write city

response.end

多增加response.write进行调试,还有<!-- #include file="..\share\connectdb.asp"&nbs