0

我正在查询一个 Dbf 文件,我想在 C# 控制台应用程序中完全加入两个查询。但 Microsoft.jet.oledb.4.0 似乎不支持完全加入。运行查询时出现以下错误。

IErrorInfo.GetDescription 失败,出现 E_FAIL(0x80004005)。

这是表详细信息和所需的查询行为。

采购和销售交易存储在表 Mtrans.DBF 中。It_type 字段用于区分采购交易和销售交易。我想将一个项目的销售和采购数量组合在一行中。

但是,如果我使用左连接或内连接或右连接而不是完全连接,则查询运行顺利,没有任何错误。请帮助我。如果此错误有任何解决方法,我请求这里的专家提出一些建议。

这是我的查询表达式

OleDbDataAdapter da = new OleDbDataAdapter();

da = new OleDbDataAdapter("select purtran.it_name,purtran.it_code,
purtran.purcqnty,purtran.puruqnty,saltran.cqnty,
saltran.uqnty,saltran.avalue from 
(select first(it_name) as    
it_name,mtrans.it_code,sum(cqnty) as purcqnty,sum(uqnty)
as puruqnty 
from mtrans 
where date >=#" + fdt + "# and 
date <=#" + tdt + "# and  (voucher is null  or len(voucher) =0)
 and it_type = '01' 
group by it_code) as purtran
full join
(select it_code,sum(cqnty) as cqnty,
sum(uqnty) as uqnty,sum(avalue) as avalue,first(tp1) as tp1 
from mtrans 
where date >=#" + fdt + "# and date <=#" + tdt + "# 
and (voucher is null or len(voucher) = 0) and 
it_type = '02' group by it_code)
saltran  
on saltran.it_code = purtran.it_code ", con);
da.Fill(dt);
4

1 回答 1

1

不,Access 不支持 FULL JOIN。您需要执行 LEFT JOIN 并使用 UNION ALL 与 RIGHT JOIN 组合结果。请参阅本教程

于 2014-06-08T15:55:39.987 回答