OLEDB conn giving error

L

liju

Hi,

I am facing a problem while trying to execute a simple mdx query using
C# and OLEDB conn.
The code I am using is as:

// Create a OleDb(!!)-connection
OleDbConnection oleDbConn = new OleDbConnection();
// Set the connectionstring
oleDbConn.ConnectionString = "Provider=MSOLAP.2;Data
Source=localhost;Initial Catalog=FoodMart 2000;";
// Creacte a new command
OleDbCommand cmd = new OleDbCommand();
// Assign the connection to the command
cmd.Connection = oleDbConn;
// Assign a query to the commandtext
cmd.CommandText = "SELECT { [Time].&[1997] } ON COLUMNS , {
[Store].[Store State].&[WA] } ON ROWS FROM [Sales] WHERE (
[Customers].[Name].&[1370], [Measures].[Unit Sales] )";
// Open the connection
oleDbConn.Open();
// Execute the reader
OleDbDataReader reader = cmd.ExecuteReader();
while(reader.Read())
{
// for each item in the resultset, print the value
for(int i = 0; i < reader.FieldCount; i++)
{
Response.Write(reader.GetValue(i));
}
}
// Don't forget to close the connection
oleDbConn.Close();

This works fine when the 'datasource' specified is 'localhost' but
gives an exception at the 'oleDbConn.Open();' statement when i am using
any other machine name which has analysis sevices.The error is 'No
error information available: E_FAIL(0x80004005)'.
What could be the possible reasons for this.Is it authentication issue?
I dont think there is any problem with connection string.

Please Advice.
Thanks and Regards.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top