|
刚才被一个很小的问题搞s了
调试能正常通过的代码如下所示:
-
- set rs=server.CreateObject("ADODB.RecordSet")
- sql="select * from answer1 where xm=' "&xm&" ' "
- sql=sql&" and zw="&zw&""
- 'Response.Write sql
- 'Response.End
- rs.open sql,conn,3,2
- '职务和姓名相同的话,提示已经输入过
- if rs.eof then
- '录入新信息
- rs.addnew
- rs("xm")=xm
- rs("zw")=zw
- rs.update
- response.write "录入成功"
- else
- response.write"<script>alert('您已经提交成功,请不要重复输入!');location='default.htm'</script>"
- response.end
- end if
- rs.close
- set rs=nothing
- response.redirect "result.aspx"
复制代码
xm--姓名,字符文本型
zw--职务,数字型
我当时这样写
-
- sql="select * from answer1 where xm= "&xm&" "
- sql=sql&" and zw="&zw&""
复制代码
或者这样写
-
- sql="select * from answer1 where xm=' "&xm&" ' "
- sql=sql&" and zw=' "&zw&" ' "
复制代码
程序都有问题,出来的结果不正常
写成第一个code就没问题
估计是数据类型不能随便乱写
因为我是拿来就用的 ,原理不是很懂,有达人可以指点一下,感激不尽 |
|