如何在更新数据库时加以条件限制?

lxg 2000-02-24 05:07:00
c=90
conn.execute("updata tb set name=sss where id=c")
为何tb表中所有记录的name都为sss?where 条件这样写对么?
...全文
174 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
chassis 2001-10-14
  • 打赏
  • 举报
回复
工作
dragoncircle 2000-03-29
  • 打赏
  • 举报
回复
如果变量是一个字符串,在变量两边加上CHR(34),包你万一无失。
karlx 2000-02-29
  • 打赏
  • 举报
回复
conn.execute("update tb set name=sss where id=CInt('" & c & "')")
july 2000-02-25
  • 打赏
  • 举报
回复
conn.execute("updata tb set name=sss where id="+string(c))
wweijie 2000-02-24
  • 打赏
  • 举报
回复
如果id为varchar,name为int,那么你写的sss一定是变量了。
应写为:
conn.execute("update tb set name=" & sss & " where id='" & c & "'")
lxg 2000-02-24
  • 打赏
  • 举报
回复
如果id为varchar,name为int,又该如何写呢?谢谢 !
cloud 2000-02-24
  • 打赏
  • 举报
回复
conn.execute("update tb set name='sss' where id=" & c)

conn.execute("update tb set name='sss' where id='" & c & "'" )

注意在&两边有空格.

dengdun 2000-02-24
  • 打赏
  • 举报
回复
name字段如果是varchar,id字段如果是int,则应该这么写:
conn.execute("update tb set name='sss' where id=" & c)
name字段如果是varchar,id字段如果也是varchar,则应该这么写:
conn.execute("update tb set name='sss' where id='" & c & "'")



lxg 2000-02-24
  • 打赏
  • 举报
回复
按你的方法试验,出现如下错误:“参数不足,期待是1!”
dengdun 2000-02-24
  • 打赏
  • 举报
回复
conn.execute("update tb set name=sss where id=" & c)

28,390

社区成员

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

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