ACCESS:跨数据库查询的SQL语句

来源:互联网 发布:linux做文件服务器 编辑:程序博客网 时间:2024/06/07 02:47
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
问题说明: 有时需要在两个或三个数据库的表中,通过相关关键字,查询获取所需记录集,用一般的SQL查询语句是实现不了的,可通过ACCESS的跨库查询功能实现。
 
解决方法: 例如“装材类型”和“装材”两张表是在不同的数据库中的,具体查询方法,如下:
@"Select * from 装材类型 as a INNER JOIN [;database=" + AppDomain.CurrentDomain.BaseDirectory + "装材.zc].装材 as b ON a.BH=b.LXBH"
 
详细解释: [;database=path;pwd=12].A
ACCESS的跨库是通过中括号实现的,包括路径,密码设置等;跨库的前提是已经打开了一个Connection。 <script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>