您好我正在尝试使用此组件: https ://www.nrecosite.com/pivot_data_library_net.aspx
我看到在这个项目中他们使用 sqlLite 作为连接字符串。
不幸的是,当我更改 connectionString 时:
new SqlGroupByCube("northwind",
new PivotDataConfiguration() {
Dimensions = new[]{"CategoryName","OrderDate_year","OrderDate_month","ProductName","CompanyName","Country","Region","City"},
Aggregators = new[] {
new AggregatorFactoryConfiguration("Count",null),
new AggregatorFactoryConfiguration("Sum", new object[] { "LineTotal" }),
new AggregatorFactoryConfiguration("Average", new object[] { "Quantity" })
}
},
new System.Data.SQLite.SQLiteConnection("Data Source="+ System.Web.HttpContext.Current.Server.MapPath("~/App_Data/northwind.db") ),
@"
SELECT ProductName, CategoryName, CompanyName, Country, Region, City, OrderDate_year, OrderDate_month, COUNT(*) as cnt, SUM(LineTotal) as LineTotal_Sum, AVG(Quantity) as Quantity_Average FROM (
SELECT p.ProductName, c.CategoryName, CAST(strftime('%Y',o.OrderDate) as integer) as OrderDate_year,
CAST(strftime('%m', o.OrderDate) as integer) as OrderDate_month, cust.CompanyName, cust.Country,
cust.Region, cust.City, od.Quantity, CAST( (od.Quantity*od.UnitPrice) as REAL) as LineTotal
FROM [Order Details] od
LEFT JOIN [Orders] o ON (o.OrderID=od.OrderID)
LEFT JOIN [Products] p ON (p.ProductID=od.ProductID)
LEFT JOIN [Categories] c ON (c.CategoryID=p.CategoryID)
LEFT JOIN [Customers] cust ON (cust.CustomerID=o.CustomerID)
) t
GROUP BY ProductName, CategoryName, CompanyName, Country, Region, City
"
) {
Name = "Northwind DB Orders (example of SQL data source)"
}
到这个连接字符串:
string connetionString = "Data Source=" + @"192.168.192.168\SqlServer" + ";
Initial Catalog=SomeDbName;User ID=Name;Password=SomePassword";
pvtRepository = new PivotRepository(
new ICube[] {
new SqlGroupByCube("SomeName",
new PivotDataConfiguration() {
Dimensions = new[]{ "appname", "dbname", "db_path"},
Aggregators = new[] {
new AggregatorFactoryConfiguration("Count",null),
}
},
new SqlConnection(connetionString),
@"SELECT TOP 1000 [some_column],[some_column1],[some_column2],[db_path]FROM [SomeDbName].[dbo].[some_table]"
)
{
Name = "My Data Test"
}
我无法在此行的 SqlGroupByCube.cs 中获取数据并失败:
var groupedPvtDataReader = new GroupedSourceReader(
dbCmdSource,
"cnt" // column name with rows count for each entry
);
try
{
var pvtDataFromGroupBy = groupedPvtDataReader.Read(PvtCfg, PvtDataFactory);
}
catch(Exception ex)
{
//somehandler..
}
在异常中我只得到“cnt”。请帮忙。