数据库为access,主要是connection属性不知道怎么设置啊,如下:ADOquery1.sql.add(‘select   *       
       from   table1   as   t1   
      where     exists(   
          select   *     
              from   table2   as   t2   
              where   t1.f1=t2.f1)‘);     
   
t1和 t2分别是两个数据库中的表,ADOquery1的connection属性设置的是adoconnection1,但t2是通过adoconnection2连接的这样就不能查询啊,有没有解决的办法啊
谢谢

解决方案 »

  1.   

    用CONNECTION连接TABLE1所在库1.mdbSelect * from table1 as t1
    where Exists(
    Select * from Table2 in '库2.MDB' as t2 where t1.f1=t2.f1未测试!
      

  2.   

    'select * from 表1 in '+QuotedStr(另一数据库路径);
    方式如上,自己根据实际情况做一些变更
      

  3.   

    我是这样写的,ComboBox1.Text中是所选的表,edit2.text中存放的另一个数据库的路径
    如下:
    ADOquery1.sql.add('select *  from   ComboBox1.Text   ');
      ADOquery1.sql.add('where   exists ( select   *   from   ComboBox2.Text 
                                           in  '+''''+edit2.text+'''   )');但系统报错是“找不到文件D:\源代码\ComboBox1.mdb”,怎么冒出个ComboBox1.mdb啊!
    请教!
    请教!
      

  4.   

    参考一下http://topic.csdn.net/t/20051206/23/4442543.html这个贴子
    是可以同时访问两个mdb数据库的
    如果是sqlserver或oracle等可以建立DBlink来实现多个数据库的访问
      

  5.   

    ADOquery1.sql.add('select *  from  '+ComboBox1.Text  );
      ADOquery1.sql.add('where  exists ( select  *  from  '+ComboBox2.Text+' in  '+''''+edit2.text+'''  )'); 试试。