如何在C#中连接到Analysis Services项目? [英] How Can I Connect To Analysis Services project In C#?
问题描述
我想连接到C#中的分析服务.
例如在c#应用程序
1.当我点击一个按钮然后创建一个挖掘结构时,
2.当我单击另一个按钮,然后使用决策树算法或其他算法预测一个字段时.
我不知道连接到分析服务需要什么连接字符串和什么命令文本.
如果有人有简单的示例代码,请帮助我
非常感谢:-)
Hi,
I want to connect to analysis service in c#.
For example in c# application
1.when I click on a button then create a mining structure,
2.when I click on another button then predict one field with decision tree algorithm or other algorithms.
I don''t know what connection string and what command text I need for connecting to analysis service.
If anybody has a simple sample code please help me
thanks a lot:-)
推荐答案
嗨 使用Microsoft.AnalysisServices.AdomdClient;
有一个用于预测一个字段的示例代码:
Hi using Microsoft.AnalysisServices.AdomdClient;
there is a sample code for predicting one field:
DataSet ds = new DataSet();
AdomdConnection myconnect = new AdomdConnection(@"provider=olap;initial catalog=datamining_studentdb;datasource=reza-pc");
AdomdDataAdapter mycommand = new AdomdDataAdapter();
mycommand.SelectCommand = new AdomdCommand();
mycommand.SelectCommand.Connection = myconnect;
mycommand.SelectCommand.CommandText = "SELECT t.[ID],[Students].[Average], PredictProbability
([Students].[Average]) From [Students] PREDICTION JOIN OPENQUERY ([Student],''SELECT [ID],[name],[average],[session] FROM [dbo].[students]'') AS t ON [Students].[Name] = t.[name] AND [Students].[Average] = t.[average] AND[Students].[Session] = t.[session]";
myconnect.Open();
mycommand.Fill(ds, "tbl");
myconnect.Close();
dataGridView1.DataSource = new DataView(ds.Tables[0]);
对于其他连接字符串,必须参考数据挖掘扩展"(DMX)语言并在相关站点中进行搜索.
祝你好运
and for other connection string must refer to ''data mining extension''(DMX) language and search in related sites.
GOOD LUCK
这篇关于如何在C#中连接到Analysis Services项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!