数据库里的的性别只有3种1,2,3 .然后DBGRID里显示的时候,1要显示为"男性",2显示为"女性",3显示为"半男不女"; DBgrid里更新的时候,比如把"男性"更新成为"半男不女",就要把数据库里的1改为3
请问如何实现..感谢,奉上50分.
PS:数据库已经不允许修改.

解决方案 »

  1.   

    update yourtable set sex=3 where sex=1
      

  2.   

    做个姓别表,在用到这个表的地方用lookup字段。
      

  3.   

    DBGRID.DataSource.DataSet.OnSetText;
                              OnGetText;
    中處理就可!
      

  4.   

    用DBGRIDEh可直接设置
    去51delphi下一个吧
    很多人都用这个的
      

  5.   

    这样做行不行
    在数据表组件中新建一字段“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  
      

  6.   

    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;
      

  7.   

    更新的时候用的是Navigator的话,如何更新呢?
      

  8.   

    即使用Navigator修改,还是需要写代码;因在DBGrid中看到的是汉字,而真正修改的却是数字,所以更新前要得到性别对应的数字;
      

  9.   

    to aiirii(ari-爱的眼睛):
    DBGRID.DataSource.DataSet.OnSetText;
                              OnGetText;
    有这2个事件吗?我怎么找都找不到,请教
    to  maimaizhi(mutiny) 是ACCESS数据库,似乎不支持case
      

  10.   

    select 编号,姓名,'男' as 性别 from table where 性别=1 union select 编号,姓名,'女' as 性别 from table where 性别=2 union select 编号,姓名,'半男不女' as 性别 from table where 性别=3
      

  11.   

    to  insert2003(高级打字员) :用DbgridEh 如何实现
      

  12.   

    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