Monday, March 26, 2012

how to run XMLA file in C Sharp?

how to run XMLA file in C Sharp

You need to execute an AdomdCommand. In your C# project, you need to add reference to Microsoft.AnalysisServices.AdomdCleint. If you have a non query DDL (such as creating a mining structure), the following example will do the trick:

try

{

using (AdomdCommand cmd = conn.CreateCommand())

{

cmd.CommandText = DDL;

cmd.ExecuteNoQuery();

}

}

catch(Exception ..)

{

}

In the example, DDL is a string contains your XMLA script. If you are running a query, you may want to call cmd.ExecuteReader to obtain a data reader.

Cheers,

|||sorry, but with a XMLA file, i want to build another database in analysis service, and i get XMLA file from exists database, i want to run it from C# project to create new database on another computer, because i can't create data source or data DSV from statement?
With DDL as you say, my XMLA file to long to put in to C# project, if i put it in C# project, DDL will be in many rows, it will return error.
please explain for me clearly
thanks|||

Your DDL should be a string in C# like this:

string DDL;

and you can read your XMLA script from a XML file into this string. Or you can append your xmla script line by line like this:

StringBuilder DDLBuilder = new StringBuilder();

DDLBuilder.Append(" <Envelope xmlns=\"http://schemas.xmlsoap.org/soap/envelope/\">");

DDLBuilder.Append("<Body>");

.....

DDLBuilder.Append("</Envelope>");

DDL = DDLBuilder.ToString();

Now you have you script in a string without put it in multiple lines. I hope this will help for your job.

Good luck,

No comments:

Post a Comment