可以呀,也就是说你的两个dbgrid可以指向一个datasource.
但这两个dbgrid 中显示的数据就一直是一样的。

解决方案 »

  1.   

    可以,动态改变datasource的连接数据源;
      

  2.   

    还是用QUERY写SQL吧,学好点SQL Server就行了。
      

  3.   

    还是用QUERY写SQL吧,学好点SQL Server就行了。
      

  4.   

    可以,但如你是不同的表和dbgrid的话,只有在代码中动态改变了,
    当然,我认为如能在静态时没好就一个表一个datasource
      

  5.   

    动态切换datasource的dataset属性就可以了
      

  6.   

    哎,这样不如用两个Tdatasource呢;
    不然,要动态的换Dataset,可能会产生抖动
      

  7.   

    我以前实现的一个方法:
    在一个pageControl上有40个tabsheet,每一个上都有各种控件,每次打开该tabsheet则自动将控件连到该datasource上。咦,我好像是答非所问。
    for i:=0 to ComponentCount-1 do
           begin
           if Components[i] is TDBcomboBox then
              with Components[i] as TDBcomboBox do
                begin
                dataSource:= DataSource2;  //指向一个空的DataSource2,相当于清空。不清空会出故障。
                if Tag = pageNo+1 then
                   DataSource := needDataSource;
                end;
           if Components[i] is TDBedit then
              with Components[i] as TDBedit do
                begin
                dataSource:=DataSource2;
                if Tag = pageNo+1 then
                   DataSource := needDataSource;
                end;
           if Components[i] is TDBmemo then
              with Components[i] as TDBmemo do
                begin
                dataSource:=DataSource2;
                if Tag = pageNo+1 then
                   DataSource := needDataSource;
                end;
           if Components[i] is TDBcheckBox then
              with Components[i] as TDBcheckBox do
                begin
                dataSource:=DataSource2;
                if Tag = pageNo+1 then
                   DataSource := needDataSource;
                end;
           if Components[i] is TDBImage then
              with Components[i] as TDBImage do
                begin
                dataSource:=DataSource2;
                if Tag = pageNo+1 then
                   DataSource := needDataSource;
                end;
         end;