这样做行不行 在数据表组件中新建一字段“Sex”,类型为String 在此字段的OnGetText事件中如下处理 if 数据表组件.recordcount>0 then begin if **.fieldbyname('性别').asstring=1 then text:='男' if **.fieldbyname('性别').asstring=2 then text:='女' if **.fieldbyname('性别').asstring=3 then text:='半男不女' end; 更新则用楼上的方法 update TableName set sex=3 where sex=1
update TableName set sex=3 where sex=1 query1. with query1 do begin close; sql.clear; sql.add('select 性别=sex case when 1 then '男性' case when 2 then '女性' when 3 else '半男不女' end from table'); open; end;
to aiirii(ari-爱的眼睛): DBGRID.DataSource.DataSet.OnSetText; OnGetText; 有这2个事件吗?我怎么找都找不到,请教 to maimaizhi(mutiny) 是ACCESS数据库,似乎不支持case
select 编号,姓名,'男' as 性别 from table where 性别=1 union select 编号,姓名,'女' as 性别 from table where 性别=2 union select 编号,姓名,'半男不女' as 性别 from table where 性别=3
to insert2003(高级打字员) :用DbgridEh 如何实现
ALTER TABLE 表 ADD 性别_2 char(8) update 表 性别_2='男' where 性别=1 update 表 性别_2='女' where 性别=2 update 表 性别_2='不男不女' where 性别=3 select 性别_2 as 表 from 表 alter table 表 drop 性别_2
OnGetText;
中處理就可!
去51delphi下一个吧
很多人都用这个的
在数据表组件中新建一字段“Sex”,类型为String
在此字段的OnGetText事件中如下处理
if 数据表组件.recordcount>0 then
begin
if **.fieldbyname('性别').asstring=1 then
text:='男'
if **.fieldbyname('性别').asstring=2 then
text:='女'
if **.fieldbyname('性别').asstring=3 then
text:='半男不女'
end;
更新则用楼上的方法
update TableName set sex=3 where sex=1
query1.
with query1 do begin
close;
sql.clear;
sql.add('select 性别=sex case when 1 then '男性' case when 2 then '女性' when 3 else '半男不女' end from table');
open;
end;
DBGRID.DataSource.DataSet.OnSetText;
OnGetText;
有这2个事件吗?我怎么找都找不到,请教
to maimaizhi(mutiny) 是ACCESS数据库,似乎不支持case
update 表 性别_2='男' where 性别=1
update 表 性别_2='女' where 性别=2
update 表 性别_2='不男不女' where 性别=3
select 性别_2 as 表 from 表
alter table 表 drop 性别_2