XMLA from the Command line
I was very suprise to don't find a tool to execute XMLA Script from the command line. Then I have decided to write it and it have been simple.
Let do it !
1) Use the useful namespace
using
Microsoft.AnalysisServices.AdomdClient;
using
System.Data;
using
System.IO;
using
System.Xml;
2) Start by connecting to Analysis Services 2005 using Adomd.
strConnectionString =
"Data Source=" + ServerID + ";";
objConnection =
new AdomdConnection();
objConnection.ConnectionString = strConnectionString;
objConnection.Open();
3) And just execute the Command
AdomdCommand
objCommand;
XmlReader objReader;
FileStream objStream;
objCommand =
new AdomdCommand();
objCommand.Connection = objConnection;
objStream =
new FileStream(objScript, System.IO.FileMode.Open, System.IO.FileAccess.Read, System.IO.FileShare.Read);
objCommand.CommandStream = objStream;
objReader = objCommand.ExecuteXmlReader();
objReader.MoveToContent();
objReader.Read ();
Console.WriteLine (objReader.ReadInnerXml());
That's All !
Comments
- Anonymous
November 22, 2005
good