Monday, March 26, 2012

How can I process my cube from a windows form?

I prefer c#.net but if you only know VB.net that would be helpful. Even if you know how to do it from a command prompt, that would be very helpful. I am using SSAS2005.

This is the xmla file that it generates when I go to script the command, I dont know if this helps.


Code Snippet

<Batch xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
'>http://schemas.microsoft.com/analysisservices/2003/engine">http://schemas.microsoft.com/analysisservices/2003/engine">
; <Process xmlns:xsd="http://www.w3.org/2001/XMLSchemahttp://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema</A< A>>" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instancehttp://www.w3.org/2001/XMLSchema-instance">http://www.w3.org/2001/XMLSchema-instance</A< A>>" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2http://schemas.microsoft.com/analysisservices/2003/engine/2">http://schemas.microsoft.com/analysisservices/2003/engine/2</A< A>>" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2">
'>http://schemas.microsoft.com/analysisservices/2003/engine/2/2">http://schemas.microsoft.com/analysisservices/2003/engine/2/2">
; <Object>
<DatabaseID>MRSTATSanalysis</DatabaseID>
<CubeID>MRSTATS</CubeID>
</Object>
<Type>ProcessFull</Type>
<WriteBackTableCreation>UseExisting</WriteBackTableCreation>
</Process>
</Batch>

Thank you all.

I found this code in a different thread, but it should work here. This code reads the xmla from a file.

Code Snippet

using System.IO;
using Microsoft.AnalysisServices.AdomdClient;

public class XmlaExecutor
{
public static void Main(string[] args)
{
TextReader tr = File.OpenText(args[0]);
string xmla = tr.ReadToEnd();
tr.Close();
AdomdConnection cn = new AdomdConnection("Data Source=localhost");
cn.Open();
AdomdCommand cmd = cn.CreateCommand();
cmd.CommandText = xmla;
cmd.ExecuteNonQuery();
cn.Close();
}
}

|||Thanks a lot, that worked perfectly. The only thing I had to do was add the .NET reference to Microsoft.AnalysisServices.AdomdClient.|||

You can also use AMO (Microsoft.AnalysisServices.dll), the management object model for Analysis Services 2005. ADOMD.NET (Microsoft.AnalysisServices.AdomdClient.dll) is mostly for querying data, while AMO is for management tasks like process, backup, restore, create, delete objects.

Quick info on AMO: http://adriandu.spaces.live.com/

Sample AMO code to create and process a partition: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=516918&SiteID=1

Adrian Dumitrascu

No comments:

Post a Comment