我用了myQuery : TAdoQuery 和 myDBGrid : TDBGrid,希望 myDBGrid  动态关联 myQuery ,如何实现啊, 同时在数据表中有个字段为DATA_TYPE 但我希望在myDBGrid 中
当Data_Type =1 时 显示 '有效'字符串 , =2 时显示 '无效' , =3 时,显示'不确定'
这功能是如何实现的呀?
 大虾们给予支持啊!

解决方案 »

  1.   

    1、放一个DataSource,指定myDBGrid的DataSource为它,指定这个DataSource的DataSet为myQuery,就关联起来了
    2、可以在SQL语句中处理:
    select Data_Type=case when Data_Type=1 then '有效' 
                          when Data_Type=2 then '无效' 
                          when Data_Type=3 then '不确定' end from table ...
      

  2.   

    myDBGrid.DataSourse:=连到myQuery的DataSourse
      

  3.   

    大虾啊,能把SQL 语句的写法详细点吗? 
      

  4.   

    你可以用INI文件进行连接!
    有问题请发信息到我的E-mail:[email protected]
      

  5.   

    select case when Data_Type=1 then '有效' 
                when Data_Type=2 then '无效' 
                when Data_Type=3 then '不确定'
           end as DataType  /*这是一个字段*/
    from table ...
      

  6.   

    myDBGrid.DataSourse.Dataset := myQuery;
      

  7.   

    mySql:='select field1,field2,Data_Type=case when Data_Type=1 then ''有效'' '+
           'when Data_Type=2 then ''无效'' '+
           'when Data_Type=3 then ''不确定'' end '+
           'from table where ...';这样可以么?
    field1,field2...表示其它字段
      

  8.   

    不行,我没调通,有没有标准的SQL 语句处理啊
      

  9.   

    大虾来一段标准SQL语句吧!!!!!
      

  10.   

    好呀,我用的是Access ,数据库名为myDB, 如表名为myTB, 字段为Card_ID , Data_Type,
    数据类型,Text, long 数据为
           Card_ID , Data_Type
               1       1
               2       2
    如何要得到上述结果,SQL 该如何编写,我在delphi 中使用,希望用标准的SQL 语句啊
      

  11.   

    完了!Access不支持Case语句,用union吧:
    select Card_ID,'有效' as Data_Type
    from myTB 
    where Data_Type=1
    union
    select Card_ID,'无效' as Data_Type
    from myTB 
    where Data_Type=2
    union
    select Card_ID,'不确定' as Data_Type
    from myTB 
    where Data_Type=3
      

  12.   

    eZou(送分大王来啦) :
    小弟,heixiu1980(迷茫ing) 的方法行吗?   我觉得可以用SQL语句调用ACCESS数据库啊   也支持CASE语句啊
      

  13.   

    感谢 heixiu1980(迷茫ing),行啊,此种方法是可以的.
    分儿一定给, 还有其他的方法吗
      

  14.   

    呵呵,你新建三个CAL字段,不知道你用过没有!!!就是双击ADOQUERY出现的字段编辑筐里!!!