Bilješka
Pristup ovoj stranici zahtijeva provjeru vjerodostojnosti. Možete pokušati da se prijavite ili promijenite direktorije.
Pristup ovoj stranici zahtijeva provjeru vjerodostojnosti. Možete pokušati promijeniti direktorije.
After you connect to an analytical data source, use an AdomdCommand object to run commands and return results. Use Multidimensional Expressions (MDX), Data Mining Extensions (DMX), or limited SQL syntax to retrieve data. Use Analysis Services Scripting Language (ASSL) commands to change the underlying database.
Creating a command
Create a command before you run it. Use one of two methods:
Use the AdomdCommand constructor with the command to run and an AdomdConnection object for the data-source connection.
Call the CreateCommand method on the AdomdConnection object.
Use the CommandText property to get or set the command text. A command doesn't have to return data when it runs.
Running a command
After you create an AdomdCommand object, use one of its Execute methods to run a command or return results. The following table describes some of these methods.
| To | Use this method |
|---|---|
| Return results as a stream of data | ExecuteReader to return an AdomdDataReader object |
| Return a CellSet object | ExecuteCellSet |
| Run commands that don't return rows | ExecuteNonQuery |
| Return an XMLReader object that contains the data in an XML for Analysis (XMLA) compliant format | ExecuteXmlReader |
Example of running a command
This example uses an AdomdCommand object to run an XMLA command. The command processes the Adventure Works DW cube on the local server without returning data.
void ExecuteXMLAProcessCommand()
{
//Open a connection to the local server
AdomdConnection conn = new AdomdConnection("Data Source=localhost");
conn.Open();
//Create a command, and assign it an XMLA command to process the cube.
AdomdCommand cmd = conn.CreateCommand();
cmd.CommandText = "<Process xmlns=\"http://schemas.microsoft.com/analysisservices/2003/engine\">\r\n" +
@"<Object>
<DatabaseID>Adventure Works DW Standard Edition</DatabaseID>
<CubeID>Adventure Works DW</CubeID>
</Object>
<Type>ProcessFull</Type>
<WriteBackTableCreation>UseExisting</WriteBackTableCreation>
</Process>";
//Execute the command
int result = cmd.ExecuteNonQuery();
//Close the connection
conn.Close();
}