我正在使用以下代码在C#中执行查询:
// Create Connection String
AdomdConnection testConnection = new AdomdConnection("Data Source=*****;User ID=******;Provider=MSOLAP.6;Persist Security Info=True;Impersonation Level=Impersonate;Password=******");
// Test Open
testConnection.Open();
// Make Query
AdomdCommand cmd = new AdomdCommand(@"SELECT { [Measures].[Payment Amount] } ON COLUMNS,
{ [Charging Low Orgs].[Charging Division].[Charging Division] } ON ROWS
FROM [Payments]", testConnection);
AdomdDataReader dataReader = cmd.ExecuteReader();
// Close Connection
testConnection.Close();
我在cmd.ExecuteReader()调用中不断收到此错误:
{“XML for Analysis解析器:未指定CurrentCatalog XML / A属性。”}
我能找到的与此相关的唯一文献是查询未解析,因为没有设置模拟,但我在连接字符串中指定了。
我认为另一篇文章并不相关,据说可以在Excel上启用BAM,但我在Excel中没有这个选项,我看不出它会如何对Web服务产生影响。
请帮忙!
答案 0 :(得分:3)
以下示例在连接字符串中包含目录参数:
static void Main(string[] args)
{
AdomdConnection conn = new AdomdConnection(
"Data Source=localhost;Catalog=Adventure Works DW Standard Edition");
conn.Open( );
string commandText = "SELECT {[Measures].[Sales Amount], " +
"[Measures].[Gross Profit Margin]} ON COLUMNS, " +
"{[Product].[Product Model Categories].[Category]} ON ROWS " +
"FROM [Adventure Works] " +
"WHERE ([Sales Territory Country].[United States])";
AdomdCommand cmd = new AdomdCommand(commandText, conn);
AdomdDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);