OLEDBDataAdapter或Datatable的不良行为

时间:2016-06-23 14:10:24

标签: vb.net ms-access oledbcommand oledbdataadapter

我正在VB.Net中开发一个桌面应用程序,其数据库是Microsoft Access 2013数据库。 但是我遇到了一个奇怪的问题,我不知道可能是什么原因。 我正在使用的查询(语句)在Access中正确返回数据,但是当使用OledbAdapters获取数据时,它在最后两列中返回空白。

我的查询语句如下,(我已经从OledbCommand.Select命令的Text Visualizer中复制了Query语句,并在Access Query中测试了它的结果)

TRANSFORM Sum(Sal_Statement.TotalPay) AS SumOfTotalPay
SELECT Sal_Statement.ZoneName, Sal_Statement.District, Sal_Statement.Empid, Sal_Statement.PANNum, Sal_Statement.BankName, Sal_Statement.IFSCCode, Sal_Statement.AccountNumber
FROM Sal_Statement
WHERE ((([Amonth] & "-" & [AYear])="Apr-2014" Or ([Amonth] & "-" & [AYear])="May-2014" Or ([Amonth] & "-" & [AYear])="Jun-2014" Or ([Amonth] & "-" & [AYear])="Jul-2014" Or ([Amonth] & "-" & [AYear])="Aug-2014" Or ([Amonth] & "-" & [AYear])="Sep-2014" Or ([Amonth] & "-" & [AYear])="Oct-2014" Or ([Amonth] & "-" & [AYear])="Nov-2014" Or ([Amonth] & "-" & [AYear])="Dec-2014" Or ([Amonth] & "-" & [AYear])="Jan-2015" Or ([Amonth] & "-" & [AYear])="Feb-2015" Or ([Amonth] & "-" & [AYear])="Mar-2015"))
GROUP BY Sal_Statement.ZoneName, Sal_Statement.District, Sal_Statement.Empid, Sal_Statement.PANNum, Sal_Statement.BankName, Sal_Statement.IFSCCode, Sal_Statement.AccountNumber
PIVOT [Ayear] & "-" & IIf([AMonth]="Jan",1,IIf([Amonth]="Feb",2,IIf([Amonth]="Mar",3,IIf([amonth]="Apr",4,IIf([amonth]="May",5,IIf([amonth]="Jun",6,IIf([amonth]="Jul",7,IIf([amonth]="Aug",8,IIf([amonth]="Sep",9,IIf([amonth]="Oct",10,IIf([amonth]="Nov",11,12)))))))))));

访问结果

Image1: Result in MSAccess - Observe Last Two Columns returned by Query

相同的查询语句返回DataTable,如下图所示

Image2: Result in DataTable-Last Two Columns are missing

0 个答案:

没有答案