数据库中游标的问题?

wangfox 2002-12-02 10:25:27
username="dd"
sql="select * from aa where UserName='" & username & "'"
set rst=server.CreateObject ("adodb.recordset")
rst.Open sql,conn,3,2
if rst.RecordCount < 1 then
rst.addnew()
end if
rst("age")=51
rst.update()
我是想从数据库先查找一个人,没有就增加一条新记录,有就在原记录上修改。
我的数据库中有一个dd,但是不知道为什么没有修改呢。
...全文
37 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
gaopq_11 2002-12-02
  • 打赏
  • 举报
回复
你的rs.recordcount不能用
我用我的机子运行了你的程序,可以实现
arclala 2002-12-02
  • 打赏
  • 举报
回复
rst.Open sql,conn,3,3
cheqiang 2002-12-02
  • 打赏
  • 举报
回复
你这种游标好象是向一个方向游动吧,而当前游标正停留在末端,当然取不到上面的记录,所以为空!
wangfox 2002-12-02
  • 打赏
  • 举报
回复
我不明白的是错误的原因。
response.write rst.RecordCount
居然为-1
我非常纳闷。
iStringTheory 2002-12-02
  • 打赏
  • 举报
回复
username="dd"
sql="select * from aa where UserName='" & username & "'"
set rst=server.CreateObject ("adodb.recordset")
rst.Open sql,conn,1,1
if not rst.eof then
conn.execute("UPDATE aa SET age='51' WHERE UserName='" & username & "'")
end if
rst.close
set rst=nothing
conn.close
set conn=nothing
wangfox 2002-12-02
  • 打赏
  • 举报
回复
充许。
iStringTheory 2002-12-02
  • 打赏
  • 举报
回复
UserName允许空么?
wangfox 2002-12-02
  • 打赏
  • 举报
回复
为什么我的rs.recordcount不能用
是SQL问题?odbc问题?iis问题,还是操作系统问题。
老大,不能始终都有问题。

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧