关于mssql7的问题

fstao 2000-01-06 11:51:00
delphi的问题:
假如用MSSQL7建一新表table1,其数据和字段如下(id1为int,f1和f2为numeric,f3为char):
id1 f1 f2 f3
1 0 yes
2 0
3 0
4 0 yes

在form1添加button1,其click事件为:
with query1 do
begin
close;
sql.clear;
sql.text:='update table1 set f2=f2+1 where f3=''yes''';
Execsql;

close;
sql.clear;
sql.text:='update table1 set f1=f2';
Execsql;

end;
table1.Refresh;

这样每按一次button1,当f3为“yes”时,则f1和f2自动增1。如果我想这样,把f1的字段类型改为char,如何实现
每按一次button1,则f1则变为“第1次”、“第2次”、“第3次”等等。例如,第一次运行form1,按button1,则
id1 f1 f2 f3
1 第1次 1 yes
2 0
3 0
4 第1次 1 yes

再按一次button1,则
id1 f1 f2 f3
1 第2次 2 yes
2 0
3 0
4 第2次 2 yes

这样以此类推,那么如何在修改button1的onclick事件?
...全文
96 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tiger 2000-01-06
  • 打赏
  • 举报
回复
update table1
set f1 = substring(f1,1,1)+
convert(varchar, convert(int, substring(f1,2,1))+ 1)+
substring(f1,3,1)
where f3 = 'yes'

5,379

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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