2016-08-25 34 views
2

我用下面的代碼來執行在C#中的查詢:查詢OLAP多維數據集通過ASHX服務

 // 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分析器分析:本CurrentCatalog XML /沒有被指定的屬性。」}

,我能找到,這是relavent到這一點的唯一文獻是,查詢不被解析導致模擬沒有設置,但我在連接字符串中指定。

另一篇我不認爲是相關的文章,說在Excel上啓用BAM,但我沒有Excel中的這個選項,我也沒有看到這對Web服務會有什麼影響。

請幫忙!

回答

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); 
+0

謝謝!我對連接字符串進行了一些混淆處理,但我認爲該數據源中的數據將被假定爲「\」。 – Stunna

相關問題