I have problem with executing query using SqlCommand
, I'm using ExecuteScalar()
method and passing open query to it:
SELECT * FROM OpenQuery(MY_OLAP,
'WITH MEMBER [Measures].[Out] AS
''[Measures].[Hours]''
SELECT NON EMPTY [Machine].[Stops].[All]
ON ROWS, [Measures].[Out] ON COLUMNS FROM [Machines]')
and trying to execute query against linked OLAP server but only thing
I get is object=null
or empty result, but when I run same query in management studio it's returning correct values.
SqlConnection cubeConnection = new SqlConnection(cubeConnectonString);
using (SqlCommand cubeCmd = new SqlCommand(cubeQuery, cubeConnection))
{
cubeConnection.Open();
var tmp = cubeCmd.ExecuteScalar();
if (tmp==null) {
cuberesult = "0";
}
else tmp.ToString();
}
I added linked OLAP server than I add linked server login with my domain user in order to have access to this cube, I login to server using standard authentication, but this doesn't help. Some one have idea what I'm missing.
EXEC sp_addlinkedserver
@server='MY_OLAP',
@srvproduct='',
@provider='MSOLAP',
@datasrc='MYSQLSERVER',
@catalog='CUBE'