zblb.asp中的部分代码如下:
for i=0 to rs.fields.count-1
response.write "<td><B>" & rs.fields(i).name & "</B></td>"
next
response.write "</tr>"
do while not rs.eof
response.write "<tr>"
for i=0 to rs.fields.count-1
response.write "<td>" & rs.fields(i) & "</td>"
next
sid= rs("id")
rs.movenext
response.write "<td><a href=""edit.asp?tt=sid"">编辑</a></td></tr>"
loop
edit.asp的全部代码
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>编辑值班信息</title>
<link href="style.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
color: #00789F;
font-weight: bold;
}
.style2 {color: #009ACE}
-->
</style>
</head>
<body>
<%
ID=request.querystring("tt")
Set Conn = Server.CreateObject("ADODB.Connection")
CONNSTR="driver={microsoft access driver (*.mdb)};dbq="+server.mappath("duty.mdb") +";"
conn.open CONNSTR
set rs=server.createobject("adodb.recordset")
sql="select * from duty where id="+id
set rs=conn.execute(sql)
%>
<table border="1" width="62%" align="center">
<tr>
<td width="17%">值班时间</td>
<td width="41%"><input name="zbsj" type="text" id="zbsj" value="<%=rs("值班时间")%>">
* </td>
<td width="42%"><div align="left">电话号码</div></td>
</tr>
<tr>
<td width="17%">值班领导</td>
<td width="41%"><input name="zbld" type="text" id="zbld" value="<%=rs("zb_ld")%>">
*</td>
<td width="42%"><input name="ldtel" type="text" id="ldtel" value="<%=rs("tel_ld")%>" maxlength="11"></td>
</tr>
<tr>
<td width="17%">值班支队</td>
<td width="41%"><input name="zbzd" type="text" id="zbzd" value="<%=rs("zb_zd")%>">
*</td>
<td width="42%"><input name="zdtel" type="text" id="zdtel" value="<%=rs("tel_zd")%>" maxlength="11"></td>
</tr>
<tr>
<td width="17%">一所值班</td>
<td width="41%"><input name="one" type="text" id="one" value="<%=rs("zb_one")%>">
*</td>
<td width="42%"><input name="onetel" type="text" id="onetel" value="<%=rs("tel_one")%>" maxlength="11"></td>
</tr>
<tr>
<td width="17%">二所值班</td>
<td width="41%"><input name="two" type="text" id="two" value="<%=rs("zb_two")%>">
*</td>
<td width="42%"><input name="twotel" type="text" id="twotel" value="<%=rs("tel_two")%>" maxlength="11"></td>
</tr>
<tr>
<td width="17%">戒毒所值班</td>
<td width="41%"><input name="jds" type="text" id="jds" value="<%=rs("zb_jds")%>">
*</td>
<td width="42%"><input name="jdstel" type="text" id="jdstel" value="<%=rs("tel_jds")%>" maxlength="11"></td>
</tr>
<tr>
<td>拘留所值班</td>
<td><input name="jls" type="text" id="jls" value="<%=rs("zb_jls")%>">
*</td>
<td><input name="jlstel" type="text" id="jlstel" value="<%=rs("tel_jls")%>" maxlength="11"></td>
</tr>
</table>
<table width="200" border="0" align="center">
<tr>
<th scope="col"><form name="form1" method="post" action="zb_save.asp">
<input type="button" name="Submit" value="修改">
</form><th scope="col"><form name="form2" method="post" action="zb_del.asp">
<input type="button" name="Submit" value="删除">
</form></th>
</tr>
</table>
<p align="center"> </p>
<p align="center"> </p>
<p> </p>
</body>
</html>
zb_save.asp代码如下:
<% Set Conn = Server.CreateObject("ADODB.Connection")
CONNSTR="driver={microsoft access driver (*.mdb)};dbq="+server.mappath("duty.mdb") +";"
conn.open CONNSTR
set rs=server.createobject("adodb.recordset")
sql="select * from duty where id= " +request("id")
rs.open sql,connstr,1,2
rs("值班时间")=zbsj
rs("zb_ld")=zbld
rs("zb_zd")=zbzd
rs("zb_one")=one
rs("zb_two")=two
rs("zb_jds")=jds
rs("zb_jls")=jls
rs("tel_ld")=ldtel
rs("tel_zd")=zdtel
rs("tel_one")=onetel
rs("tel_two")=twotel
rs("tel_jds")=jdstel
rs("tel_jls")=jlstel
rs.update
rs.close
%>
zb_del.asp代码如下
<%
Set Conn = Server.CreateObject("ADODB.Connection")
CONNSTR="driver={microsoft access driver (*.mdb)};dbq="+server.mappath("duty.mdb") +";"
conn.open CONNSTR
set rs=server.createobject("adodb.recordset")
sql="select * from duty where id= " +request("id")
rs.open sql,connstr,1,2
rs.delete
rs.close
%>
在zblb.asp页面点击“编辑”后,出现如下错误:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 'id=' 中。
/edit.asp, 第 28 行
28行是 set rs=conn.execute(sql)