» 首页 » 电脑_数码 » 编程 » ASP网站后台提问:修改不了数据库,说是数据库中无数据

ASP网站后台提问:修改不了数据库,说是数据库中无数据

<!--#include file="ly.asp"-->

<%dim action
action=request.QueryString("action")
if action="sheding" then
set rs=server.CreateObject("adodb.recordset")
rs.Open "select * from cp",conn,1,3
rs("if_index_xianshi")=trim(request("if_index_xianshi"))

rs.update
rs.close
set rs=nothing

end if %>



<form name="form1" method="post" action="index_cpt_guanli.asp?action=sheding">。


<input name="if_index_xianshi" type="text" id="if_index_xianshi" value="<%=rs("if_index_xianshi")%>">
<input type="submit" name="Submit" value="确定这三个">
<label>
<input type="reset" name="Submit2" value="重设">
</label></td>
</tr>
</form>

大概就是这样,中间用了
if err.number<>0 then
response.write "数据库中无数据"
end if
测试。一按确定就出来数据库中无数据,不知道哪里错了,请大家指教


士为知己者死
权限不够或连接文件有问题
兄弟你真逗,怎么加
if err.number<>0 then
response.write "数据库中无数据"
end if

这样搞笑的东西啊
你直接写成
if err.number<>0 then
response.write "出错了"
end if
不就行了吗,你得到的提示“数据库中无数据”是因为你出错了,而非真正的无数据,出错原因是,你的表单中的
<input name="if_index_xianshi" type="text" id="if_index_xianshi" value="<%=rs("if_index_xianshi")%>">
你运行一下,第一次运行时,由于没有得到action的值,所以不执行数据库操作,那么肯定没有rs对象是吧,所以这时就已经有错误了
接着,我们继续,假设你屏蔽了错误,那么,我们 提交一个数据,会发现,你操作数据库了,但是很可惜你马上又关闭了,所以到这个表单这里,调用rs 给这个表但中的这个文本框赋值时,惊奇的发现,rs对象咋又没呢……

明白了没?
我不明白大家为什么要这样写程序:

rs.Open "select * from cp",conn,1,3
rs("if_index_xianshi")=trim(request("if_index_xianshi"))
rs.update

我觉得标准的方法应该是:

sql="update cp set if_index_xianshi='&trim(request("if_index_xianshi"))&' where ID=指定的ID"
rs.Execute sql,conn
换链接字符串或者查SQL语句

 相关问题
·ASP网站后台提问:修改不了数据库,说是数据库中无数据
·重用一个人之后,发现了他的才能,要是更加重用他,他会...
·SQL代码的实现
·怎么用方正飞腾 书籍排版
·有没有MATLAB高手帮我看下这个程序。
·汇编中如何实现输入输出?
·关于SQL 2000中cd-key 的问题
·js 算术运算结果
·asp 文本框
·会用 Outlook Express的高手请教!
·关于matlab的 xlswrite 请教高手~
·MPC104AU BB SOP是什么?
·protel 单片机仿真
·谁能帮我改下这个代码,让他只显示图片,而不是所有的文件
·asp中如何用Access数据库中的数据控制柱形图,请给出详细...

 《ASP网站后台提问:修改不了数据库,说是数据库中无数据》答案收集时间:2008-06-14 14:49:23



©2007 电脑技术问答录