Reputation: 2000
This is the connection string used within excel, I was wondering if there was any way to connect to this database using vb.net to bring back data via SQL.
In other words how can I use this connection string in my web application
<odc:OfficeDataConnection
xmlns:odc="urn:schemas-microsoft-com:office:odc"
xmlns="http://www.w3.org/TR/REC-html40">
<odc:Connection odc:Type="OLEDB">
<odc:ConnectionString>Provider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=True;Initial Catalog=[databasename];Data Source=[servername];MDX Compatibility=1;Safety Options=2;MDX Missing Member Mode=Error</odc:ConnectionString>
<odc:CommandType>Cube</odc:CommandType>
<odc:CommandText>PnL</odc:CommandText>
</odc:Connection>
</odc:OfficeDataConnection>
I have tried this below, but it doesn't seem to work, any ideas?
Dim Conn As OdbcConnection = New OdbcConnection("DProvider=MSOLAP.4;Integrated Security=SSPI;Persist Security Info=True; " _
& " Initial Catalog=[databasename];Data Source=[servername];MDX Compatibility=1;Safety Options=2;MDX Missing Member Mode=Errora")
Upvotes: 0
Views: 751
Reputation: 5831
What it looks like your Office Data Connection is pointing to is a SQL Server Analysis Services instance (judging by the provider being MSOLAP.4
and the CommandType being Cube
) so you I don't think you will be able to connect to it using an OdbcConnection or similar.
You probably need to use ADOMD.NET to establish a connection and run your queries. Also, it won't be SQL you're writing but probably something like a MDX query - the Client Programming guide should have some more specific guidance about how to do that.
Upvotes: 1